-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore_conditionalArrows.js
More file actions
24 lines (20 loc) · 911 Bytes
/
Core_conditionalArrows.js
File metadata and controls
24 lines (20 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 1. Write an arrow function that checks to see if a user is older than 18.
const isAdult = (age) => age>=18
? "You are good to go!"
: "Sorry! You must be 18 or older!";
console.log(isAdult(17));
// 2. Write an arrow function that checks to see if it is currently raining.
const isRain = (rain) => rain
? "Get your rain jacket!"
: "No rain on today's forecast!";
console.log(isRain(true));
// 3. Write an arrow function that checks to see if a number is even.
const checkEvenNumber = (number) => number % 2 == 0
? "That's an even number!"
: "That's an odd number!";
console.log(checkEvenNumber(21));
// 4. Write an arrow function that takes in two parameters and checks whether one number is greater than another.
const chechBigNumber = (num1, num2) => num1 > num2
? `${num1} is more than ${num2}!`
: `${num1} is less than ${num2}!`
console.log(chechBigNumber(111,22));