javascript - Need help on very simple if statement in function -
javascript - Need help on very simple if statement in function -
i maintain getting "syntaxerror: unexpected identifier" here code:
var sleepcheck = function(numhours){ if numhours >= 8 { homecoming "string 1"; else { homecoming "string 2"; } } sleepcheck(10)
what doing wrong?
you need wrap assessment in parentheses:
var sleepcheck = function(numhours){ if (numhours >= 8) { homecoming "string 1"; else { homecoming "string 2"; } } sleepcheck(10)
for single-statement if
/else
omission of curly braces legitimate:
var sleepcheck = function(numhours){ if (numhours >= 8) homecoming "string 1"; else homecoming "string 2"; } sleepcheck(10)
as semi-colons (unfortunately); parentheses obligatory.
javascript
Comments
Post a Comment