lundi 30 mai 2016

Javascript if statement with no else statement

function checksound(volume){
if (volume > 30)
sound = ‘loud’;
if (volume > 20)
sound = ‘good’;
if (volume > 0)
sound = ‘quiet’;
else sound = ‘no sound’;
return sound;
}

If the volume was entered as 31 would it return loud? I'm not sure as there is no else statement.

Aucun commentaire:

Enregistrer un commentaire