Note: Javascript Noob (just started learning today)
For practice with loops/dialogs, I'm making a simple "what number am I thinking of" program.
<script language="javascript" type="text/javascript">
var num = 7;
while(num = 7)
{
num = prompt("What number am I thinking of? From 1-10");
if(num != 7)
{
document.write("try again <br/>");
}
else
{
document.write("you got it");
}
}
</script>
So I partially have it working. When the user inputs 7 (which is what I'm thinking of) it will return "you got it" but it keeps prompting the user for input. I think I've created an infinite loop because my browser gets a bit messed up every time I run it.
How would I be able to stop the program from running after the user inputs the correct number? Also if you have any suggestions on how I could do this differently or better, I'm all ears.