logo CodeStepByStep logo

loopMystery6

Language/Type: JavaScript for loops loop mystery
Author: Melissa Hovik (on 2016/09/25)

What is the output of the following JavaScript code?

for (let i = 1; i <= 10; i++) {
    let mystery = "";
    for (let j = 1; j <= 10 - i; j++) {
        mystery += " ";
    }
    for (let j = 1; j <= 2 * i - 1; j++) {
        mystery += "*";
    }
    console.log(mystery);
}
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.