Help With Loops


#1

Could someone take a look at my code and tell me where I screwed up my While loop? I can't figure it out.

// Write your code below!
var x= function(number){

for (;number<13;number++){console.log(number);}
}
x(1)

var y = function(number){
while(number<14){number++;console.log(number)

}
}
y(2)

var z = function(number){
    do {console.log("Searching...");}
    while(number<20){ number++; console.log("Search Complete.")
    }}
z(1)

#2

@immediategratificati,
In your

var z = function(number){
    do {console.log("Searching...");}
    while(number<20){ number++; console.log("Search Complete.")
    }}

You are concatenating the DO-WHILE with a WHILE statement
and
the DO-WHILE definition would cause an Infinite loop as you are not incrementing the number variable in its DO-body....

the for-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for

the while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while

the do-while-loop:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while