html - JavaScript Unknown Error in Code -


so im making simple guessing game , numbers go 1-10. issue whenever guess number right still says wrong here source code program. (is proper meaning of source code?)

    <!doctype html>     <html>     <head>     <title>first proper html page</title>     </head>      <body>      <h3>hello world</h3>     <p>this first website</p>     <p>its fun , exciting</p>     <p><a href="http://xkcd.com" title="xkcd:land of geeky comics!">click here </a>     <script>     var randomnumber = math.floor(math.random(100) * 11);     //console.log(randomnumber);     var guess = prompt("please guess number 1 - 10");     if(guess === randomnumber){     alert("you have won! number " + randomnumber);     }else{     alert("you have guessed wrong number, real number  " +              randomnumber);     }     </script>      </body>     </html> 

you using strict comparison (===), evaluate value , type equal, believe should use parseint in guess follows:

if(parseint(guess) === randomnumber){ 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -