1
I need to create a while loop that sent a message x number of times to the console.
var loop = function(){
while(){
console.log("");
}
}
loop();
1
I need to create a while loop that sent a message x number of times to the console.
var loop = function(){
while(){
console.log("");
}
}
loop();
3
Just create a condition:
var loop = function(x) {
qtd = 0;
while (qtd < x) {
console.log("Mensagem #" + qtd);
qtd++;
}
}
loop(10);
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
If you already have the number x of times why not use one() ?
– Wagner Soares
Yes, using the for would be easier, but I would like to learn how it would work to make the same question that would be asked with the for but with the while.
– otarampinelli