repl.it
@MIhm7904/

ProblemSet4

Nodejs

Problem Set 4: Console.log and Conditional Statements

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// let time = 22
// if (time < 12){
//   console.log("Good Morning!")
// } else if(time > 12 && time < 17){
//   console.log("Good Afternoon!")
// } else if(time > 17){
//   console.log ("Good Evening!")
// } else {
//   console.log("Hello!")
// }

//Write a program that prints a message to the screen based on a users age and country.
//Feel free to change these variables or create new ones so you can test all cases.

const age = 21
const country = "UK"

//if the user is younger than 16 print "You're not old enough to do anything yet."
//if the user is at least 16 but not yet 18 print "Be careful driving."
//if the user is 18 but not yet 21 and the user lives in the USA print "Go Vote!"
//if the user is at least 18 but younger than 21 and lives outside of the USA print "You can probably have some wine."
//In all other cases print "Your're old enough to figure it out for yourself."
if (age < 16){
  console.log("You're not old enough to do anything yet.")
}else if (age >= 16 && age < 18){
  console.log("Be careful driving.")
}else if (age >= 18 && age < 21 && country === "USA"){
  console.log("Go Vote!")
}else if (age >= 18 && age < 21 && country !== "USA"){
  console.log("You can probably have some wine.")
}else{
  console.log("You're old enough to figure it out for yourself.")
}