showing results for - "javascript if else and else if"
Louisa
03 Aug 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 }
Lydia
03 May 2019
1if (condition1) {
2  //  block of code to be executed if condition1 is true
3} else {
4  //  block of code to be executed if the condition1 is false
5}
Alessia
12 Feb 2016
1if (condition) {
2  //  block of code to be executed if the condition is true
3}
4//-------------
5if (hour < 18) {
6  greeting = "Good day";
7}
8//-------------
9if (condition) {
10  //  block of code to be executed if the condition is true
11} else {
12  //  block of code to be executed if the condition is false
13}
14//-------------
15if (hour < 18) {
16  greeting = "Good day";
17} else {
18  greeting = "Good evening";
19}
20//-------------
21if (time < 10) {
22  greeting = "Good morning";
23} else if (time < 20) {
24  greeting = "Good day";
25} else {
26  greeting = "Good evening";
27}
28
similar questions
queries leading to this page
javascript if else and else if