logo CodeStepByStep logo

loopMystery10

Language/Type: JavaScript while return

For each call of the function below, write the output that is printed and the value that is returned:

function loopMystery10(x, y) {
    let z = x + y;
    let result = "";
    while (x > 0 && y > 0) {
        x = x - y;
        y--;
        result += (x + " " + y + " ");
    }
    console.log(result + y);
    return z;
}
loopMystery10(7, 5) output
loopMystery10(7, 5) return
loopMystery10(20, 4) output
loopMystery10(20, 4) return
loopMystery10(40, 10) output
loopMystery10(40, 10); return

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.