fork download
  1. // Define the function under this line
  2. var canIDrive = function(myAge, legalDrivingAge){
  3. if(myAge >= legalDrivingAge){
  4. return true;
  5. }
  6. else{
  7. return false;
  8. }
  9. };
  10.  
  11.  
  12.  
  13. // Declare legalDrivingAge under myAge
  14. var myAge = prompt("How old are you?");
  15. var legalDrivingAge = 18;
  16. //Create an if else statement using the function as a condition
  17. if (canIDrive()) {
  18. console.log("You can legally drive!");
  19. }
  20. else {
  21. console.log("You'll have to wait a few more years!");
  22. }
  23.  
Runtime error #stdin #stdout 0.29s 213248KB
stdin
Standard input is empty
stdout
Standard output is empty