Forum : loop
Brief description  about Online courses   join in Online courses
View manjulambigai  karthikeyan 's Profile

loop

Guessing any number between 1 to 20. run the loop till you not get correct number. For that use prompt() box.

for this below code is correct or not

var i=prompt("Please enter no where the loop stop between 1 to 20"," 0");
i = Number(i);
var x=1;
if(x!=i)
{document.write( x "<br/>");
x ;}
document.write("The loop Stop here");
</script>
Asked by manjulambigai karthikeyan | Apr 13, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Manjulambigai,

Code is correct. I think this is from loop assignment, so you need to use loop concept. Better simply print the numbers until you get user entered number between 1 to 20.
Apr 19, 2010