Codington
0 of 8 problems solved • 0%

Exercise prompt

Recognize an Out-of-Range Index

Reading an index that does not exist produces undefined.

Example

const names = ["Ava"]; console.log(names[3]); // outputs undefined

Predict the output

A scoreboard tries to display the final player's score. Trace how it chooses the index and predict the output.

const scores = [8, 10]; console.log("Final score:", scores[scores.length]);
What will this code print?