0% found this document useful (0 votes)
29 views5 pages

Learning Sheet ICT 10-3 Week 06

The document discusses JavaScript if-else statements. It describes three forms: the if statement, if-else statement, and if-else if statement. The if statement executes code if the condition is true. The if-else statement executes one block of code if the condition is true and another block if false. The if-else if statement checks multiple conditions in sequence. Examples are provided to demonstrate each statement type. The learning objectives are to understand how to use if-else if statements in JavaScript programming. Activities are included for students to practice the different statement types.

Uploaded by

Robert Pugayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views5 pages

Learning Sheet ICT 10-3 Week 06

The document discusses JavaScript if-else statements. It describes three forms: the if statement, if-else statement, and if-else if statement. The if statement executes code if the condition is true. The if-else statement executes one block of code if the condition is true and another block if false. The if-else if statement checks multiple conditions in sequence. Examples are provided to demonstrate each statement type. The learning objectives are to understand how to use if-else if statements in JavaScript programming. Activities are included for students to practice the different statement types.

Uploaded by

Robert Pugayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Learning Sheet ICT 10

JavaScript If-Else Statement

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. }

Flowchart of JavaScript If statement


Let’s see the simple example of if statement in JavaScript.

<script>

var a=20;
if(a>10){
document.write("the value of a is greater than 10")
}

</script>

JavaScript If...else Statement


It evaluates the content whether condition is true of false. The syntax of JavaScript if-
else statement is given below.

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. }

Flowchart of JavaScript If...else statement


Let’s see the example of if-else statement in JavaScript to find out the even or odd
number.

<script>

var i=20;
if(i<15)
document.write("10 is less than 15")

else
document.write("I am not in if")
</script>

JavaScript If...else if statement


It evaluates the content only if expression is true from several expressions. The
signature of JavaScript if else if statement is given below.

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

See the example below:


<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>

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:

Robert S. Pugayan Jr.


TLE Subject Teacher

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.

You might also like