Ret = prompt('Type the word castle',"");
if statement - use this statement if you want to execute a set
of code when a condition is true
In the example above, the if statement compares the character string "print" to the var1 to test the condition. The next statment is a block of JS code that will execute if var1 is equal to print.
See the example used earlier to get a demonstration on how the is/else block works.
The switch statement is basically an enhanced version of the "if-else" statement that is more convenient to use when you have code that needs to choose a path from many to follow.
A switch statement is essentially the same as a series of "if" and "else-if" statements. "So, what's the point of even having a switch statement", you may ask. Well, it's simple to use, logical in syntax, and most importantly, many programmers swear by it.