HTML code:
<form>
Input: <input type="text" name="input" id="input"><br>
<br>
Output: <input type="text" name="output" id="output"><br>
<input type="submit" value="submit" onclick="yourGuess()" id="submit">
</form>
<div id="answer"></div>
Script
I can't figure out how to get the code to compare input to the words in the array and come out with a correct or wrong answer and put it in the div (id=answer).
function yourGuess()
{
var n = 0;
var words = ['banana', 'orange', 'apple', 'peach'];
var guess1 = document.getElementById("input").value;
//wrong answer
if (guess1 !== words) {
document.getElementById("answer").innerHTML = "Wrong!";
}
else {
//right answer
if (guess1 == words) {
document.getElementById("answer").innerHTML = "Correct!";
}
</body>