Learning Sheet ICT 10-3 Week 06
Learning Sheet ICT 10-3 Week 06
JavaScript If-else
The JavaScript if-else statement is used to execute the code whether condition is true
or false. There are three forms of if statement in JavaScript.
1. If Statement
2. If else statement
3. if else if statement
JavaScript If statement
It evaluates the content only if expression is true. The signature of JavaScript if
statement is given below.
1. if(expression){
2. //content to be evaluated
3. }
<script>
var a=20;
if(a>10){
document.write("the value of a is greater than 10")
}
</script>
1. if(expression){
2. //content to be evaluated if condition is true
3. }
4. else{
5. //content to be evaluated if condition is false
6. }
<script>
var i=20;
if(i<15)
document.write("10 is less than 15")
else
document.write("I am not in if")
</script>
1. if(expression1){
2. //content to be evaluated if expression1 is true
3. }
4. else if(expression2){
5. //content to be evaluated if expression2 is true
6. }
7. else if(expression3){
8. //content to be evaluated if expression3 is true
9. }
10. else{
11. //content to be evaluated if no expression is true
</script>
Learning Objectives:
At the end of the lesson, the students are expected to:
1. Perform how to use if else if statement in JavaScript programming.
Activity 01
Directions: Perform the given codes below:
<script>
var a=30;
if(a>15){
document.write("the value of a is greater than 10")
}
</script>
<script>
var i=20;
if(i<15)
document.write("10 is less than 15")
else
document.write("I am not in if")
</script>
<script>
var a=20;
if(a==10){
document.write("a is equal to 10");
}
else if(a==15){
document.write("a is equal to 15");
}
else if(a==20){
document.write("a is equal to 20");
}
else{
document.write("a is not equal to 10, 15 or 20");
}
</script>
Prepared by:
Noted:
_______________________
Activity 1: Rubrics
Points Description
10 The student successfully executes the program without guidance or supervision.
The student successfully executes the program with very little supervision and
9
guidance.
The student successfully executes the program with moderate supervision andguidance.
8
The student was not able to execute the program but shows eagerness to accomplishthe
7
activity.
5 The student was not able to execute the program due to lack of interest in the activity.