+ 2
please explain answer
The following code will result in what value? function test(number) { while(number < 5) { number++; } return number; } alert(test(2));
3 Respuestas
+ 12
Function test accepts a number as a parameter and increments it while the number is smaller than 5. The function returns the number after the loop ends. Hence, the function will always return 5 for values smaller than 5.
alert(test(2)) will result in output of 5.
0
5
0
The code below the result
Counter =0
While counter<4:
Print( counter)