If statement
Let year = prompt('In which year was ECMAScript-2015 specification published?', '');
*!*
if (year == 2015) alert( 'You are right!' );
*/!*
Gets a condition, evaluates it and, if the result is true, executes the code.
Else clause
Let year = prompt('In which year was ECMAScript-2015 specification published?', '');
if (year == 2015) {
alert( 'You guessed it right!' );
} else {
alert( 'How can you be so wrong?' ); // any value except 2015
}
The if statement may contain an optional "else" block. It executes when the condition is wrong.