-
Notifications
You must be signed in to change notification settings - Fork 10
/
template.js
51 lines (25 loc) · 1.7 KB
/
template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Arrays
// Create an array of numbers, 1 through 10
// Write a function, called forLoop that takes an array as a parameter, runs the array through a for(...) loop and does a console.log() of each element.
// Write a function, called whileLoop that takes an array as a parameter, runs the array through a while(...) loop and does a console.log() of each element.
// Implement .map(), .filter(), .reduce() as regular javascript functions that take in an array as a parameter, but do the same things as the real functions.
// Objects
// Begin with the starter code below ...
const people = ['Kookla','Fran','Ollie'];
const stuff = {
tv: 'huge',
radio: 'old',
toothbrush: 'frayed',
cars: ['Toyota','Mazda']
}
// Using spread and destructuring assignment, create a new array called `newPeople', which is a copy of the `people` array, with a person named 'Odie' added to the beginning and one named 'Garfield' added to the end.
let newPeople = [];
// Using spread and destructuring assignment, create a new object called `newStuff', which is a copy of the `stuff` object, with a new car added to the end of the `cars` array within it
const newStuff = {};
// Create a `state` object with keys of people and stuff that contain the `people` and `stuff` data.
// Do this using object destructuring assignment
let state = {};
// Using spread and destructuring assignments, create a new object called `newSate`, repeating the `newPeople` and `newStuff` steps above but directly within the people and stuff nodes of the state object (don't just spread in `newPeople` and `newStuff`)
let newState = {};
// Prove that the original people, stuff, and state are unchanged.
// const people = ['Kookla','Fran','Ollie'];