1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
If the value of pets is ["dog","cat","fly","bug","ox"] and you write the following statement, the value of sliceOfPets is [______]. | const sliceOfPets = pets.slice(3, 4); | "bug" | •bug• |
If the value of pets is ["dog","cat","fly","bug","ox"] and you write the following statement, the value of sliceOfPets is [______]. | const sliceOfPets = pets.slice(3); | "bug","ox" | •bug•,•ox• |
The value of pets is ["dog","cat","fly","bug","ox"]. Code a slice statement that assigns "dog" and "cat" to a new array, sliceOfPets. | const sliceOfPets = pets.slice(0, 2); | constsliceOfPets=pets\.slice\(0,2\); | |
The value of pets is ["dog","cat","fly","bug","ox"]. Code a concise slice statement that assigns "fly" "bug", and "ox" to a new array, oddPets. | const oddPets = pets.slice(2); | constoddPets=pets\.slice\(2\); | |
The value of the array series is [4,6,8,10]. Code a slice statement that assigns the first element to a new array, x. | const x = series.slice(0, 1); | constx=series\.slice\(0,1\); | |
The value of the array switches is [true,true,false,true,true,false]. Code a slice statement that assigns the two middle elements to a new array, bools. | const bools = switches.slice(2, 4); | constbools=switches\.slice\(2,4\); | |
The value of the array minerals is ["carbon","iron","tungsten"]. Code a concise slice statement that assigns the last element to a new array, t. | const t = minerals.slice(2); | constt=minerals\.slice\(2\); | |
The array minerals has been declared with the let keyword. The array's value is ["carbon","iron","tungsten"]. Code a slice statement that reduces the array to the first two elements. | minerals = minerals.slice(0, 2); | minerals=minerals\.slice\(0,2\); | |
|
|||
|