I am totally new to Java. I was wondering how to use a word instead of a number in an if condition. So here's the whole code:
<!DOCTYPE html>
<html>
<body>
<p>Click the button.</p>
<button onclick="nextFunction()">Run Next Function</button>
<script>
//Next Function
function nextFunction() {
var inputA = prompt("Hello, would you like to begin?", "Y/N");
if (inputA == Y) {
var inputB = prompt("Good!", "Y/N");
}
if (inputA == N) {
alert("Okay, bye then...");
}
} //End of Next Function
</script>
</body>
</html>
So I have a prompt that pops up for the user to enter in an answer. In the text box it asks Y/N, and in ifs I have inputA == Y or N. It works perfect if I change Y to 1 and N to 0 but I want it to work with the letters, and I might use full words later on. How can I get the ifs to read the words? Thanks!
Aucun commentaire:
Enregistrer un commentaire