logo CodeStepByStep logo

loopMystery9

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 loopMystery9(i, j) {
    let result = "";
    while (i != 0 && j != 0) {
        i = parseInt(i / j);
        j = parseInt((j - 1) / 2);
        result += (i + " " + j + " ");
    }
    console.log(result + i);
    return i + j;
}
loopMystery9(5, 0) output
loopMystery9(5, 0) return
loopMystery9(3, 2) output
loopMystery9(3, 2) return
loopMystery9(16, 5) output
loopMystery9(16, 5) return
loopMystery9(80, 9) output
loopMystery9(80, 9) return
loopMystery9(1600, 40) output
loopMystery9(1600, 40) 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.