Summary
Keywords
Full Transcript
Link for all dot net and sql server video tutorial playlists http://www.youtube.com/user/kudvenkat/playlists Link for slides, code samples and text version of the video http://csharp-video-tutorials.blogspot.com/2014/11/conditional-statements-in-javascript.html Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1 JavaScript code is executed in a linear fashion from the first line to the last line. If for some reason you want to interrupt this flow and execute certain statements, only, if certain condition is met, then we use conditional statements. JavaScript has the following conditional statements if if else if else if else switch ternary operator - shortcut for an if...else statement If example var userInput = Number(prompt("Please enter a number", "")); if (userInput == 1) { alert("You number is One"); } if (userInput == 2) { alert("You number is Two"); } if (userInput == 3) { alert("Your number is Three"); } if(userInput != 1 && userInput != 2 && userInput != 3) { alert("Your number is not between 1 and 3"); } If else if example var userInput = Number(prompt("Please enter a number", "")); if (userInput == 1) { alert("You number is One"); } else if (userInput == 2) { alert("You number is Two"); } else if (userInput == 3) { alert("Your number is Three"); } else { alert("Your number is not between 1 and 3"); }
