Using only Switch statement to write the code out

var val = prompt (“enter Age”); const d = 22 ; switch (true) { case (d == 2): alert(“You are eligible”); break; case ( d >= 18 ): alert(“You are not eligible”); break; case (d >= 39): alert ( “Get a driver”); break; case (d >=59): alert (“is too old to drive a car” ); break; case (d > 60): alert (“Call your grandson to drive for you”); break; default: alert (“Drive”);

Any hint please

i understand what you want but we can not just give you answer .
so you have to write your own code and then share that code if you stuck so we can tell what’s wrong.

hint is use switch to solve this problem

syntax is

case 1 :
// code when case one is true
other cases:

can you post a link to this Challenge

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.