Teens - Teaching Test EN
Teens - Teaching Test EN
FOR LOOP
1
Timedoor Coding Academy
Meeting 4
4
PROBLEM SOLVING
PRACTICE
Now we are going to learn about another new loop called For Loop.
For Loop
Repetition of a process where we already know the number
of times it’ll repeat or commonly used for repetition with a
certain pattern.
From the code above, how many times will the command be
repeated? Check out the explanation below first!
2
Timedoor Coding Academy
Meeting 4 - Problem Solving Practice and For Loop
FOR LOOP
This means that the value will be counted by 1 for each loop. The number of fish w
keep increasing by 1 as long as the number of fish in the aquarium has not reached
+1 +1 +1
Yes Yes Yes No
To determine the loop, check the number of times +1 is
executed.
3
Timedoor Coding Academy
Meeting 4 - Problem Solving Practice and For Loop
FOR LOOP
//commands to repeat
}
Repeated Commands
4
Timedoor Coding Academy
Meeting 4 - Problem Solving Practice and For Loop
CODING PRACTICE
v
Timedoor Coding Academy
i
Timedoor Coding Academy
Meeting 6
7
WHAT IF ?
5
Timedoor Coding Academy
Meeting
6 CONDITIONAL
CASE 1
If test score is more than 70, Arjuna can enter the Intermediate
class.
This means:
What is the condition for Arjuna to enter the Intermediate Class?
What will happen if the score is less than 70?
Conditional
Term/condition for a program to be executed.
6
Timedoor Coding Academy
Meeting 6- What If
CONDITIONAL 1 CONDITION
CASE 2
If Chito is hungry, Chito will eat.
If Chito is sleepy, Chito will sleep.
If Chito will do an exam, Chito will study.
This means: :
If Chito feels hungry, what will he do?
What is the condition for Chito to sleep?
What is the condition for Chito to study?
7
Timedoor Coding Academy
Meeting 6- What If
CONDITIONAL 1 CONDITION
8
Timedoor Coding Academy
Meeting 6- What If
NESTED CONDITIONAL
9
Timedoor Coding Academy
x
Timedoor Coding Academy
Meeting 18
FUNCTION
10
Timedoor Coding Academy
Meeting
18 WHAT IS FUNCTION?
WHAT IS FUNCTION?
Observe the story below!
During lunch break, Bintang wanted to buy fried rice. He said “Hi,
I want to buy some fried rice” to the cook. Then what did the cook
do?
1. Prepare materials
2. Put the pan on the stove
3. Turn on the stove
4. Heat the oil
5. Pour the rice and other seasonings into the pan
6. Stir until cooked
7. Turn off the stove and serve the fried rice
11
Timedoor Coding Academy
Meeting 18- Function, Real or Fake?
WHAT IS FUNCTION?
Every time Bintang gives the command “Buy fried rice”. The cook
will do steps 1-7. This means that the commands of buying fried
rice already represents the steps 1 to 7. In coding it can be called
as a function.
Function
Commands that represent sequences of code to execute a
specific task and can be used over and over again.
Define a Function
Function must be created before they can be called.
Notice how to create function in JavaScript.
function functionName(){
//function body
Calling a Function
To run the code in the function body, we must call the function name.
function name
functionName();