+ 1

Âżalguien podrĂ­a explicarme como funcionan estas lĂ­neas de cĂłdigo ?.

Function test (number ) {    While (number < 5) {    number ++; } Return number; } alert(test (2));

8th Oct 2020, 2:58 PM
Nicolas Lopez
Nicolas Lopez - avatar
3 Answers
+ 1
😣
8th Oct 2020, 2:58 PM
Nicolas Lopez
Nicolas Lopez - avatar
+ 1
The function will return 5 if the tested number is 5 or smaller. Numbers bigger than 5 will return their original value. The reason is the while loop. It increases small numbers until it is 5. For bigger numbers the while loop will not run.
8th Oct 2020, 4:48 PM
Paul
Paul - avatar
0
Thank you very much.
9th Oct 2020, 11:54 AM
Nicolas Lopez
Nicolas Lopez - avatar