Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139893

Expected an assignment or function call and instead saw an expression when calling function

$
0
0

I am making a flashcard/test program. For some reason, I'm not checking the result when I call the function getAns. JSHint is giving this error:

Expected an assignment or function call and instead saw an expression.

Here's my code:

function getAns() {
  if (answer[i] == lastPress) {
    document.getElementById("ans").innerHTML = "You're correct! The answer was " + lastPress;
  } else {
    document.getElementById("ans").innerHTML = "We're sorry, but that is not correct. The answer was " + answer[i];
  }
  i++;
  document.getElementById("question").innerHTML = questions[i];
}
document.getElementById("true").onclick = function() {
  lastPress = true
};
document.getElementById("true").onclick = function() {
  getAns
};
document.getElementById("false").onclick = function() {
  lastPress = false
};
document.getElementById("false").onclick = function() {
  getAns
};

Viewing all articles
Browse latest Browse all 139893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>