What causes javascript error "Expected identifier and instead saw else"? -


error message:

"expected identifier , instead saw else." 

here's code (all javascript) :

// write function below. // don't forget call function! var sleepcheck = function(numhours) {     if (numhours >= 8); {         console.log("you're getting plenty of sleep! maybe much!");    }     else {         console.log("get more shut eye!");     } }; console.log(sleepcheck) 

shouldn't have semicolon here:

if (numhours >= 8); { 

an if statement structure should this:

if (condition) {  } else if (condtion2) {  } else {  } 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -