While loop error?
- by user134134
I believe the problem with my code lies within my while loop. Admittedly, I'm rather new to Javascript programming. Does this look okay:
<! DOCTYPE html>
<head><title>title</title></head>
<body>
<script type="text/javascript">
alert("Hello, stranger. Please note that at this current moment, we do not have a save function. It might be a good idea to record your answers.");
var preAnswer = 0;
while (var preAnswer = 0) {
var name = prompt("What is your name? Please capitalise it, for the sake of grammar.")
if (name === "")
{
alert("What are you playing at? You didn't type anything.");
var preAnswer = 0;
} else {
var preAnswer = 1
}
}
alert("Nice name, " + name + ", bro.")
</script>
</body>
</html>
I'm sure I've done something wrong, as it isn't functioning.