The if else if else Statement part 1
else if
You can use the else if statement to specify a new condition if the first condition is false.
Example:
The above code says:
- if course is equal to 1, output "HTML Tutorial";
- else, if course is equal to 2, output "CSS Tutorial";
- if none of the above condition is true, then output "JavaScript Tutorial";
course is equal to 1, so we get the following result:
The final else statement "ends" the else if statement and should be always written after the if and else if statements
What keyword is used to end the "else if" statement?
Comments
Post a Comment