Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Last active March 26, 2023 18:17
Show Gist options
  • Save sandrabosk/9d0f5b7dc0c2e2d96d1af478621a24cb to your computer and use it in GitHub Desktop.
Save sandrabosk/9d0f5b7dc0c2e2d96d1af478621a24cb to your computer and use it in GitHub Desktop.

Checking for understanding - if

Challenge 1

For this activity, create a new variable called language . Then create a conditional that handles printing:

  • Hola, Martin if language is equal to "spanish"
  • Salut, Martin if language is equal to "french"
  • Hello, Martin if language is equal to "english"
  • I am not sure what are you trying to do, sorry! 🍺 if language is equal to anything else.

Bonus: Use prompts to determine what language will be set to as well as the name that should be consoled.
Hint: For bonus part, you have to use repl.it with HTML, CSS and JS, instead only with JS.

Challenge 2

Write a program that asks the user to enter a number between 0 and 100 (inclusive) and then displays a letter grade (A, B, C, D, or F) based on the following grading scale:

  • A: 90-100
  • B: 80-89
  • C: 70-79
  • D: 60-69
  • F: 0-59

For example, if the user enters 95, the program should output "A"; if the user enters 72, the program should output "C".

To accomplish this, you can use an if statement. In the end, you can handle the case in which user inputs a number outside of the scope.

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