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

Tuesday, December 4, 2012

Codecademy: Codeyear Looking back at conditionals


//sample solution


var yourJob = "Teacher";
var dominantHand = "right";
var result;

//Line 10 starts an if statement
//Nested in this if statement is an if else statement on lines 11 - 15
//This nested if else statement allows us to check another condition
//We close the first if statement at the start of line 16

if (yourJob.length>0 && dominantHand.length>0) {
  if (dominantHand === "right" || dominantHand === "left") {
    result = "Thanks";
  } else {
result = "Please enter right or left for dominantHand.";
  }
} else {
  result = "Please tell us both your job and your dominant hand.";
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts