Practice makes perfect! problem!


#1


I've actually passed this practice but I just wanted to try another way to do the same thing.
Down below is my code.This code will make my browser crash and I can't find the error in it.
Could anyone help me with this problem?Thank you!


var loop = function(number){
	while(number<3){
		
		for(var i=1;i<4;i++){console.log("I'm looping!")};
	
		};
};	
loop(2);


#2

loop(2);

here 2 is the value you are passing as argument.
so here

var loop = function(number){
while(number<3){

means

var loop = function(2){

while(2<3){

that is always true. you have to increase the number.
add

number++

in your while loop or function


#3

@rcodeman Thank you! I forgot "while" is still a kind of loop,so I have to set a condition for it to jump out.


#4

Will it work if you pass loop(2131), for example, and could you please explain why?


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.