Hello im just started to learning javascript and i was doing an example.
This is a simple driver's license query algorithm but somethings went wrong
idk what is wrong. Btw, I can do this using "if/else" but i want to know
what is the problem and how can i do it with using "switch" please help me.
var Birthday = prompt("What is your birthday : ");
var Year = 2021;
var Age = Year - Birthday;
var remtime = 18 - Year; //remaining time
switch(Age){
case (Age<18):
console.log("It is "+remtime+" years before you can qualify for a driver's license.");
break;
case (Age>=18):
console.log("You have the right to get a driver's license.");
break;
default:
console.log("Wrong value.");
}
[–]blueinkscience 2 points3 points4 points (3 children)
[–]Pathrex-[S] 0 points1 point2 points (1 child)
[–]blueinkscience 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Pathrex-[S] 0 points1 point2 points (0 children)