Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 3, 2012

Codecademy: Codeyear Functions in if else statements


//sample solution


// Define the function under this line
var canIDrive = function(myAge,legalDrivingAge){
if(myAge>=legalDrivingAge){
return true;
} else {
return false;
}
};
// Declare legalDrivingAge under myAge
var myAge = prompt("How old are you?");
var legalDrivingAge = 18;
//Create an if else statement using the function as a condition
if (canIDrive(myAge,legalDrivingAge)) {
  console.log("You can legally drive!");
}
else {
  console.log("You'll have to wait a few more years!");
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts