Changing
JavaScript · Unit 5: Arrays
- Full plan
- JavaScript
- 12 exercises
An array can be changed after you create it. To change one item, you give it a new value using its index.
const scores = [70, 50, 90];
scores[1] = 80;
console.log(scores);Prints
[ 70, 80, 90 ]
The rest of the explanation is in the lesson, which is part of the full plan.
Exercises in this lesson
You do them in the app, which checks them on the spot and explains why.
1. Predict the output
What does this code print?
2. Complete the code
Complete it so the second product costs 25.
3. Predict the output
What does this code print?
4. Predict the output
What does this code print?
5. Predict the output
What does this code print?
6. Complete the code
Complete it so Jake ends up at the front of the line.
7. Find the bug
This program should add "Wed" at the end of the days. Which line has the error?
8. Predict the output
What does this code print?
9. Multiple choice
If
numswas created withconst, which of these lines breaks?10. Find the bug
This program should add milk to the list and print it. Which line has the error?
11. Put the lines in order
Put the lines in order to print the squares of 1 to 3.
12. Multiple choice
What does this code do to the line?
It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.