logo CodeStepByStep logo

loopMystery11

Language/Type: JavaScript while loops return

For each call of the function below, write the output that is printed as it would appear on the console.

function loopMystery11(x, y) {
    let z = y;
    let result = "";
    while (x % z == 0) {
        result += ("(" + x + " " + z + ") ");
        x = x - z;
        z++;
    }
    console.log(result + "(" + x + " " + z + ") " + y);
}
loopMystery11(12, 4);
loopMystery11(14, 2);
loopMystery11(27, 3);

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.