logo CodeStepByStep logo

starsPrint

Language/Type: JavaScript expressions %

What output is produced by each of the following code samples?

// A)
let line = "";
for (let i = 0; i < 5; i++) {
    for (let j = 0; j < 10; j++) {
        line += "*";
    }
    console.log(line);   // to end the line
    line = "";
}
// B)
let line = "":
for (let i = 1; i <= 5; i++) {
    for (let j = 1; j <= i; j++) {
        line = "*";
    }
    console.log(line);
    line = "":
}
// C)
let line = "";
for (let i = 1; i <= 5; i++) {
    for (let j = 1; j <= i; j++) {
        line += i;
    }
    console.log(line);
    line = "";
}
A)
B)
C)

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.