Question
// JavaScript Exercises console.log(Script has arrived); // Write code according to the comments below. console.log(-------------- Objects, Dictionaries, and Associative Arrays ---------------) let me = {name:
// JavaScript Exercises
console.log("Script has arrived");
// Write code according to the comments below.
console.log("-------------- Objects, Dictionaries, and Associative Arrays ---------------")
let me = {name: 'Emmett', head: 'yes', blue: 'color'};
me['head'] = 'beautiful';
me.head = 'even more beuatiful';
me.celebrate = 15;
// create an array of three objects where each object has made up values for
// name, age, and favorite_color
let objs = [
{
name: "John",
age: 30,
favorite_color: "Red"
},
{
name: "Jay",
age: 32,
favorite_color: "White"
},
{
name: "JC",
age: 34,
favorite_color: "Blue"
}
];
// change the age of the third object to 27 using associative array syntax
// using a for...of loop and object . notation, print the favorite colors
/* using a for...in loop, print the property names in the first object in the array
(i.e. name, age, favorite_color) */
// using Object.keys, print the array of keys in the second object (no loop, the whole thing)
console.log(objs,[1]);
console.log(object.values(objs[1]));
console.log(object.keys(objs[1]));
// using Object.values, print the array of values in the second object (no loop, the whole thing)
console.log("-------------- Destructuring Bind and Spread Syntax ---------------")
// write a function that returns an array of three numbers
let r = bigThree();
let min = r[0];
let max = r[1];
let q = r[2];
let [min, max, q] = bigThree();
// call that function and use destructuring syntax to assign the numbers to three separate variables
let {imprtant, vital} = someFn();
// write a function that returns an object
// call that function and use destructuring syntax to assign the property values to separate variables
// write a function that takes two named parameters using destructuring syntax
// call that function by passing in an object
// using Object.entries and a for...of loop that destructures the [key, value] pair,
/* print the second object like:
name: bob
age: 32
favorite_color: mauve */
// using spread syntax, copy your object array and add a fourth object
let h = [{}, {}, {}];
let j = [...h, {}, {}];
// using spread syntax, make a copy of the third object in the array but with the name changed to 'batbatbat'
let o = {a: 1, b: 2, v: 3};
let o2 = {...o, t: 15, b: 14};
let o3 = {};
o3.a = o.a;
o3.b = o.b;
o3.v = o.v;
o3.t = 15;
// write a function that uses spread syntax ("rest") to take a variable number of numbers and return the sum
console.log("this script is done")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started