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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -