Sometimes { } & sometimes not, don't get it


#1


I hope I can get help here. What it is, I don't get why theres no parentheses {} here. I'm shore iv'e been taught that if/els statements have parentheses now theres none but there doesn't see to be an explanation in my head as to why. I am shore the answer will have something to do with the age variable prompt.

Thanks guys.

// Check if the user is ready to play!
confirm("Are you ready to play!");

var age = prompt("What is your age");

if (age < 13) 
console.log("Your allowed to play but we take no responsibility");

else
console.log("What an exciting new game. Press play and be the first to play");


Replace this line with your code.


#2

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.