This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var name = prompt("What's yo' name?") | |
result = "Nick" ? true : false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myAge = prompt("How old are you?") | |
answer = myAge >= 18 ? "adult" : "non-adult" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var born = prompt("What country were you born in?"); | |
var result; | |
switch(born){ | |
case "USA": | |
result = 1; | |
break; | |
case "England": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myCar = "Toyota"; | |
var result; | |
switch (myCar) { | |
case "Ford": | |
result = "American brand"; | |
break; | |
case "Toyota": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canIDrive = function(myAge, legalDrivingAge){ | |
if(myAge >= legalDrivingAge){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
var myAge = prompt("How old are you?"); | |
var legalDrivingAge = 18 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var legalDrivingAge = 18; | |
var canIDrive = function (myAge){ | |
if(myAge >= legalDrivingAge){ | |
return true; | |
} else { | |
return false; | |
} | |
} | |
canIDrive(31) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var yourName = "Ash"; | |
var gender = "Blue"; | |
var result; | |
if (yourName.length > 0 && gender.length > 0) { | |
if (gender === "Male" || gender === "Female") { | |
result = "Thanks"; | |
} else { | |
result = "Please enter male or female for gender."; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use taxiFare to set tripCost to the cost of your | |
// ride covering 5 miles at 2 am in the morning | |
var tripCost; | |
// calculates taxi fare based upon miles traveled | |
// and the hour of the day in military time (0-23). | |
var taxiFare = function (milesTraveled, pickupTime) { | |
var baseFare = 2.50; | |
var costPerMile = 2.00; | |
var nightSurcharge = 0.50; // 8pm to 6am, every night |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isDivisible = function (x, y) { | |
return x % y === 0; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var area = function (w, l) { | |
// We should return the product of w and l. | |
return w*l; | |
}; |