1

I'm doing a simple project with javascript and it requires me to get a value out of an HTML text input with javascript. In the following code I've found that nothing after line 6 works and I have no idea why. This has been driving me crazy for like two hours and I'm kind of at my wits end. Please help!

function letsPlayAGame() {
  var answer = Math.floor(Math.random() * 100 + 1);

  var guess = document.getElementByID("theinput").value;

  if (Number.isInteger(guess) == false) {
    document.getElementByID("label").innerHTML =
      "Please enter a number between 1 and 100!";
  } else if (guess < 1 || guess > 100) {
    document.getElementByID("label").innerHTML =
      "Please enter a number between 1 and 100!";
  } else {
    alert("not this part");
  }
}
3
  • Can you provide relevant HTML and clarify which is line 6? Commented Jul 17, 2018 at 3:24
  • 3
    Also note that JavaScript is case sensitive, getElementById instead of getElementByID Commented Jul 17, 2018 at 3:24
  • 1
    Yep, that was the problem! Going to go and scream a bit now, thanks! Commented Jul 17, 2018 at 3:27

1 Answer 1

3

It should be:

document.getElementById

instead of

document.getElementByID

as Javascript is case sensitive.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.