JavaScript Functions
JavaScript Functions
prepared to
have fun!
Presented by Ma’am Ali
Attendanc
e
Let us
Pray.
Emoji
Story
Write or draw 3 emojis that best describe what you
felt in our previous lesson. Explain why you choose
these emojis.
Mystery
box
challenge
Try to guess the scrambled words given
inside the mystery box. Use the definitions
as clues in finding the words.
It performs the
CALLING
NIGLCNAL specified
actions with
FUNCTION
TNUCFONI the indicated
parameters
when the
function is
called.
Functions
PARAMETERS
ERSAATPMER that are
names listed
in the
function
definition.
The function
FUNCTION
NUCFONIT code that you
have written
INVOCATION
OVNIACIOTN will be
executed
whenever it is
called or
triggered by an
event.
It has a
WORAR
ARROW shorter
syntax
UNCTIIFON
FUNCTION compared and
an alternative
to function
expressions.
These
NESTED
ETSEDN functions have
access to the
FUNCTION
CTUONIFN variables and
parameters of
the outer
function,
creating a
scope
4 pics 1
word
Guess the topic for today based on the
given pictures.
F UN C T I ON
JAVASCRIPT
FUNCTIONS
Presented by Ma’am Ali
Lesson objectives
At the end of the lesson, students should be able to:
a. define the purpose of JavaScript functions,
b. use JavaScript functions in enhancing their website,
and
c. appreciate the characteristics of JavaScript
functions.
JavaScript Functions
What is a JavaScript Functions?
JavaScript Functions
is a block of code
designed to perform
a particular task.
is executed when
"something" invokes
it (calls it)
Key Characteristics of Functions
Parameters and Arguments: Functions can accept
JavaScript Functions
function multiply(a, b = 1) {
return a * b;
}
console.log(multiply(5, 2)); // Expected output: 10
syntax:
if (condition) {
/*block of code to be
executed if
the condition is true*/
}
else
Statement
Use the else
statement to
specify a block of
code to be
executed if the
condition is false.
syntax:
if (condition) {
// block of code to be executed
if
the condition is true
} else {
// block of code to be executed
if
else if Statement
Use the else if statement to specify a new
condition if the first condition is false.
syntax:
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
If time is less than 10:00, create a "Good morning" greeting, if
not, but time is less than 20:00, create a "Good day"
greeting, otherwise a "Good evening":
JavaScript functions are needed for the creation of safe
and effective website developments. If-else conditions,
return statements, nested functions, function calling,
and callback functions are some of the tools we can
use to properly authenticate users, enhance websites,
and validate user input. Functions improve code
reusability, readability, and maintainability, making
them essential for building dynamic and interactive
web applications.
Quarter 4
Quiz #1
Choose the correct answer for each
questions. Write your answers in
CAPITAL LETTERS.
1. How do you define a function in JavaScript?
A) function: myFunction()
B) function myFunction()
C) def myFunction()
quarter 4 - Quiz #1
D) myFunction()
console.log("Adult");
quarter 4 - Quiz #1
} else {
console.log("Minor");
5. What will be the result of the syntax
}
above?
A) “Adult”
B) “Minor”
C) Undefined
D) Error
Answer Key
1. A
quarter 4 - Quiz #1
2. C
3. B
4. A
5. A
Output 4.1
Login
Authentication
System
Write a login system where you can input a username
and password details. The system should accept a
username and password, check if they match the stored
credentials, and display either a success or error
message.
Output 4.1 sample
Output 4.1 Rubrics
JavaScript Functions
THANK YOU,
Class!
Prepared by: Ma’am Ali