Edit This Code:
<!DOCTYPE html>
<html>
<body>

<p>I'm thinking of a letter. Guess which: a, b, c, d or e?</p>

<input id="myInput" type="text">

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var letter = document.getElementById("myInput").value;
    var text;

    // If the letter is "c"
    if (letter === "c") {
        text = "Spot on! Good job!";
        
    // If the letter is "c" or "e"
    } else if (letter === "b" || letter === "d") {
        text = "Close, but not close enough.";
        
    // If the letter is anything else
    } else {
        text = "Waaay off..";
    }
document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy