JavaScript Arrays — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Arrays lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Create an array
easy10 minCreate an array of three fruit names and show how many it holds.
- 2
Show an empty array length
easy10 minCreate an empty array and show its length.
- 3
Store mixed types
easy10 minCreate an array holding a string, a number and a boolean, then show the type of the middle element.
- 4
Count a nested row
medium10 minCreate a grid of two rows with three values each and show the length of the first row.
- 5
Grow a const array
easy10 minPush a value onto an array declared with const and show the new length.
Find the bug(5)
- 1
Fix the missing commas
easy8 minThe array was written without separators, so it holds one value instead of three.
- 2
Fix the wrong brackets
easy8 minCurly braces make an object, not an array, so there is no length.
- 3
Fix length called as a function
easy8 minlength is a property, not a method.
- 4
Fix the flat grid
easy8 minThe grid should hold rows, but every value was put in one list.
- 5
Fix the array that was replaced
easy8 minBuilding a new array loses the earlier values instead of adding to them.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace