How can we use prompt command in this


#1

var a = prompt("enter");
var sample = function(a)
{
while(a < 5){
console.log("==>");
a= a + 1;
}
};
sample(a);


#2

What do you want to do here. One problem with this code is that prompt always returns a string so if you enter let's say 0 then prompt will turn it to "0" so when you add one to it it will not be 1 but "01" -> "011" ->"0111" aso. So perhaps using parseInt or parseFloat would be necessary.


#3

so what is the sol.?
i want something which i ask in promt command and use it in the condition?


#4

Maybe some sort of password?

x = prompt(...);
while(x !== ...){
   x = prompt(...);
}