Practice with conditionals/ Adding an else statement to my code


#1

if("golanheights".length=100)
console.log("the condition is false")
if("golanheights".length=12)
console.log("the condition is true")
I'm having trouble adding else statement to my code.


#2

if you have one condition

if(condition){
  //do somthing
}
else{
   //do somthing else
}

if you have more than one condition

if(condition){
  //do somthing
}
else if(condition){
   //do somthing else
}
else{

 //do something else
}

Note: else is not allowed to have a condition and else is not compulsory.


#3

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