<!DOCTYPE html>
<html>
<head>
<script>
var msg = "Hooray! So glad to be playing a game with you!"
var answer =""
while (answer.toLowerCase() != "yes" && answer.toLowerCase() != "y" && answer.toLowerCase().substr(0,1) != "y" &&
answer.toLowerCase() != "no" && answer.toLowerCase() != "n" && answer.toLowerCase().substr(0, 1) != "n") {
answer = prompt("Wanna play a game? y,yes,Yes - for yes or n, no, No for no: ")
}
if (answer.toLowerCase() == "no" || answer.toLowerCase() == "n" || answer.toLowerCase().substr(0, 1) == "n") {
msg = "Sorry that you don’t want to play with me :("
}
window.onload = function () {
document.getElementById("message").innerHTML = msg;
};
</script>
</head>
<body>
<p id="message"></p>
</body>
</html>
Comments
Leave a comment