showing results for - "javascript if else"
Juniper
09 Apr 2017
1if (time < 10) {
2  greeting = "Good morning";
3} else if (time < 20) {
4  greeting = "Good day";
5} else {
6  greeting = "Good evening";
7}
Emilia
18 Mar 2019
1console.log("abhishek");
2
Mathilda
09 Feb 2020
1if (condition1) {
2  //  block of code to be executed if condition1 is true
3 }
4else if (condition2) {
5  //  block of code to be executed if the condition1 is false and 
6  //  condition2 is true
7} else {
8  //  block of code to be executed if the condition1 is false and 
9  //  condition2 is false
10 }
Melody
17 Jan 2018
1var age=20;
2if (age < 18) {
3	console.log("underage");
4} else {
5	console.log("let em in!");
6}
Rafaela
09 Aug 2016
1/* Shorten if-else by ternary operator*/
2const go = "yes"
3let race = null
4
5race = go === "yes" ? 'Green Light' : 'Red Light';
6
Emanuele
26 Feb 2017
1if..else if...else
similar questions
queries leading to this page
javascript if else