Is it possible to prompt a user for a number and write out a list of numbers to the user picked number and also say next to each one whether it's odd or even?
Is it possible to prompt a user for a number and write out a list of numbers to the user picked number and also say next to each one whether it's odd or even?
Last edited by Tseng; 11-18-2008 at 01:14 PM. Reason: spelling
Here:
Code:<script type="text/javascript"> var num = prompt('Feed me a number!',''); for(i=0;i<=num;++i){ if((i/2) == Math.round(i/2)){ document.write(i+" - Even<br />"); } else { document.write(i+" - Odd<br />"); } } </script>
Jeremy | jfein.net
Code:for(var i=0; i<=num; ++i) document.write(i + " - " + ( i&1 ? "Odd" : "Even") + "<br />");
Bookmarks