if…else and switch in javascript
JavaScript code can calculate, compare, and determine true and false conditions , things start looking a lot more interesting. the power of choice into your scripts with conditional statements . These statements enable your script to evaluate given conditions on the basis of which to execute one or more actions. More specifically, you're going to learn how to use: if statements; if ... else statements; if ... else if ... else statements; switch statements. In the process, you're also going to learn how to use shortcut assignment operators . if Statement The if keyword is used in JavaScript to perform a basic test for the truth or falsity of a given condition and execute a piece of code accordingly . Here's its structure: //if the condition in brackets is true if ( condition ) { //do some stuff here } Let's translate the code Translated into English, th...