Codington
0 of 10 problems solved • 0%

Exercise prompt

Trace an Array Inside an Object

An object property can contain an array. After reading that property, array indexes and .length work as usual.

Example

const playlist = { title: "Focus", songs: ["One", "Two"] }; console.log(playlist.songs[1]); // outputs "Two"

Predict the output

An article stores its tags inside an object. Predict its last-tag and tag-count displays.

const article = { title: "Loops", tags: ["js", "arrays", "practice"] }; console.log("Last:", article.tags[article.tags.length - 1]); console.log("Count:", article.tags.length);
What will this code print?