0% found this document useful (0 votes)
3 views

Javascript Function

This document outlines a 1-hour JavaScript session focused on writing functions that handle user input and perform arithmetic operations. Participants will learn to create a program that sums two numbers and formats the output, as well as develop functions to find the maximum and minimum of given numbers. The session includes practical exercises to reinforce understanding of function anatomy, input parameters, and return values.

Uploaded by

Jinjen b.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Javascript Function

This document outlines a 1-hour JavaScript session focused on writing functions that handle user input and perform arithmetic operations. Participants will learn to create a program that sums two numbers and formats the output, as well as develop functions to find the maximum and minimum of given numbers. The session includes practical exercises to reinforce understanding of function anatomy, input parameters, and return values.

Uploaded by

Jinjen b.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

JAVASCRIPT

FUNCTION
By the end of this 1-hour session, you should be able to:

 Write a JavaScript program that accepts user input, performs basic arithmetic
operations, and displays results formatted to two decimal places.

 Demonstrate understanding of user input, data parsing, and output formatting by


using prompt(), parseFloat(), and toFixed() methods.

 Apply these skills by creating a program that sums two numbers provided by the
user and displays the result accurately in a formatted message.
Anatomy of the JavaScript
Function
Anatomy of the JavaScript
Function
Anatomy of the JavaScript
Function
Anatomy of the JavaScript
Function
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Practical Applications of Java
Script Functions
Underpinning Knowledge – Basic
Sum
Function - Sum
Seatwork Instructions:
On a 1/4 sheet of paper, write a JavaScript function that will accept two numbers
as input and display the larger of the two numbers. Ensure the function is clear and
uses appropriate variable names for readability. (5 mins)

Additional Requirements:
1.Function Name: Give the function a meaningful name that reflects its purpose.
2.Input Parameters: Use descriptive names for the parameters to indicate they are
numbers.
3.Return Value: Include a return statement to output the larger number.
4.Test the Function: After defining the function, write an example call to
demonstrate how the function works.
Example Solution:
Assignment: Find the Maximum and Minimum of Four Numbers
On a half sheet of paper, create a JavaScript function that accepts four numbers as input and
returns both the largest and smallest numbers among them. This exercise will allow you to
practice comparing multiple values and using conditional logic.

Instructions:
1.Function Name: Name the function descriptively to reflect that it finds both maximum and
minimum values.
2.Parameters: The function should accept four parameters. Use clear and descriptive names
for each parameter.
3.Logic: Use conditional statements to find the largest and smallest numbers among the four.
4.Return Value: The function should return an object containing both the largest and smallest
numbers.
5.Testing: Write example calls to the function with different sets of numbers to verify it works
correctly.
6.Edge Cases: Consider cases where two or more numbers might be equal, and ensure the
function handles these correctly.

You might also like