2

This is part of my homework but i can't figure out what is wrong and any help would be appreciated

var InputNum = prompt("Please enter a number between 50 and 100:", "");
if (isNaN(InputNum)) {
    if (InputNum.match(/one|two|three|four|five|six|seven|eight|nine|ten/)) {
        alert("while this is a number, it's not really a number to me.");
    } else {
        alert(InputNum + " doesn't appear to be a number.");
    }
} else if (InputNum >= 99 && InputNum <= 51); {
    alert("theat number, " + inputNum + ", is not between 50 and 100.");
}
document.write("The user gave a number in the range! " + inputNum + "<br>");

on line 25 it comes up with the warning that the title states.

Zaffy
  • 16,801
  • 8
  • 50
  • 77
  • 1
    How do you incorporate this script on the page? – zerkms Mar 25 '13 at 00:49
  • 3
    `InputNum >= 99 && InputNum <= 51` - Greater than (or equal to) 99 AND less than (or equal to) 51? – ahren Mar 25 '13 at 00:51
  • 2
    You must be using an XHTML doctype. In that case, either use an HTML5 doctype (` `), escape the ampersands (`&`), or [put the script block in a `CDATA` section](http://stackoverflow.com/q/66837/139010). – Matt Ball Mar 25 '13 at 00:51
  • I'm not sure my teacher gave us three different problems to debug and I did the other two and all of the only instructions for this was "debug - If statements get a number in a specific range from the user." – skeletonchoji Mar 25 '13 at 00:52
  • 4
    I notice you also seem to have a stray `;` after the `else if (InputNum >= 99 && InputNum <= 51)`... that probably should not be there, and will cause the `else if` block to be skipped I believe. – Stuart M Mar 25 '13 at 00:53
  • @MattBall tbh there is `document.write` so html is the only option – Esailija Mar 25 '13 at 00:54
  • @Jacedc Thank you i should have seen that – skeletonchoji Mar 25 '13 at 00:57

1 Answers1

8

The character & in HTML is reserved for entities, such as &nbsp; and &quot;. This error is complaining about & being misused; it is a sign you should write it as &amp; (which is the correct entity for the & symbol), or you should put your script in a context where it is not interpreted as HTML (such as CDATA).

Amadan
  • 191,408
  • 23
  • 240
  • 301
  • wonder if he is using Tidy? A quick search shows the same error http://www.htmlpedia.org/wiki/Tidy_3 – jermel Mar 25 '13 at 01:05
  • I have since figured out a way to fix my issue thank you for all the help, it was a combination of all your answers. – skeletonchoji Mar 25 '13 at 01:53