diff --git a/solutions/day-03/index.html b/solutions/day-03/index.html index e1c7bf1..4ca09f0 100644 --- a/solutions/day-03/index.html +++ b/solutions/day-03/index.html @@ -13,7 +13,7 @@ - + +

30DaysOfJavaScript: Day 04

+

Conditionals

+ + +
+
+ + + + \ No newline at end of file diff --git a/solutions/day-04/main.js b/solutions/day-04/main.js new file mode 100644 index 0000000..651e0da --- /dev/null +++ b/solutions/day-04/main.js @@ -0,0 +1,40 @@ +function canDrive() { + let age = parseInt(prompt("Enter your age.")); + + if (age < 18) { + alert("You are not old enough to drive"); + } + else { + alert("You are old enough to drive!") + } +} + +function isOlder() { + let myAge = 17; + let yourAge = parseInt(prompt("How old are you ?")); + + if (yourAge > myAge) { + alert(`You are ${yourAge - myAge} year(s) older than me.`) + } + else { + alert(`I am ${myAge - yourAge} years older than you!`) + } +} + +let a = 4; +let b = 3; + +if (a > b) { + console.log(`${a} is greater than ${b}`); +} + else{ + console.log(`${a} is less than ${b}`); + } + +switch (true) { + case (a > b): + console.log(`${a} is greater than ${b}`); + break; + default: + console.log(`${a} is less than ${b}`); +} \ No newline at end of file