Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 9 lesson 7, says complete for loop code

for...in loop to print the following output from the code:
name is JS Course
duration is 15 hours
price is 499
discount is 100%
Complete the code to get the following output. You will have to write code in the for loop's parenthesis and inside the console.log() statement.

Code i wrote:
let course = {
name: "JS Course",
duration : "15 hours",
price: 499,
discount: "100%"
};
for(keys in course)
{
console.log(`${keys} is ${course[keys]}`);
}

it says complete the for loop code, what am i missing?
by

1 Answer

sam5epi0l
As the instructions suggest, you need to use x as interpreter:

let course = {
name: "JS Course",
duration : "15 hours",
price: 499,
discount: "100%"
};

for(x in course)
{
console.log(`${x} is ${course[x]}`);
}

Login / Signup to Answer the Question.