logo CodeStepByStep logo

loopMystery12

Language/Type: JavaScript for nested loops

What does the following code print out?

let line = "";
for (let i = 1; i <= 10; i++) {
    for (let j = 1; j <= 10 - i; j++) {
        line += " ";
    }
    for (let j = 1; j <= 2 * i - 1; j++) {
        line += "*";
    }
    console.log(line);
    line = "";
}
output

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.