Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active January 16, 2023 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/ab604ccb1cbb384e69734439dce22f81 to your computer and use it in GitHub Desktop.
Save McLarenCollege/ab604ccb1cbb384e69734439dce22f81 to your computer and use it in GitHub Desktop.
Exercise Name : Cinema Discount Without Else

A cinema is showing movie to childeren (age < 18) for free and charging adults (age >= 18) with $10 per ticket.

For adults:

Please pay $10.
Please proceed to the cinema hall.

For children:

 Please proceed to the cinema hall.

CODE

let age = 34;
if(age >= 18){
  console.log("Please pay $10");
  console.log("Please proceed to the cinema hall");
}
else{
  console.log("Please proceed to the cinema hall");
}

Write code to achieve the same output WITHOUT using an else block.

Note: You can use just a single if statement

CODE TEMPLATE


let age = 34;
// write your  statements here to print the required messages according to the value of the age variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment