0% found this document useful (0 votes)
7 views4 pages

Javascript Week Five

The document outlines tasks for a week focused on Browser APIs and Functions. It includes creating single-page applications using local storage and geolocation, as well as various function-related exercises such as creating, modifying, and using different types of functions. The tasks emphasize practical application of Object-Oriented Programming principles and JavaScript function concepts.

Uploaded by

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

Javascript Week Five

The document outlines tasks for a week focused on Browser APIs and Functions. It includes creating single-page applications using local storage and geolocation, as well as various function-related exercises such as creating, modifying, and using different types of functions. The tasks emphasize practical application of Object-Oriented Programming principles and JavaScript function concepts.

Uploaded by

shop.25theve
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

WEEK FIVE

LESSON ONE: Browser APIs:


LOCALSTORAGE,GEOLOCATION, AND SESSION STORAGE

Tasks:

Task 1: Create a single page application of your choice that


would make use of the local storage as its database. This
application should be created using the OOP principle. The
design and functionality of the application is your choice to
make. Just make it simple

Task 2: Create a simple single page application that would


make use of the browser’s Geolocation API to detect the
user's current location and display the city, country, time and
altitude of the user at the moment. The design and
functionality of the application is your choice to make.

● based on each element.

LESSON FOUR: FUNCTIONS


Tasks:

Task 1: Create a basic function

● Declare a function named greet that logs a greeting message


to the console.
● Call the function to see the greeting message printed.

Task 2: Pass arguments to a function

● Modify the greet function to accept a parameter representing


a name.
● Update the function body to include the name in the greeting
message.
● Call the function with different names as arguments.

Task 3: Return a value from a function


● Create a function named multiply that takes two parameters
representing numbers.
● Multiply the two numbers inside the function and return the
result.
● Call the function and store the returned value in a variable.
● Log the variable to the console to see the multiplication result.

Task 4: Use default parameter values

● Modify the greet function to have a default parameter value of


"Guest" for the name.
● If no argument is passed when calling the function, it should
use the default value.
● Call the function both with and without passing a name
argument.

Task 5: Create a function expression

● Declare a function expression named add that adds two


numbers.
● Assign the function expression to a variable.
● Call the function using the variable and log the result.

Task 6: Use arrow functions

● Rewrite the greet function as an arrow function.


● Test the arrow function by calling it with different names.

Task 7: Understand function scope

● Create a variable inside a function and try to access it outside


the function.
● Declare a variable outside a function and try to access it
inside the function.

Task 8: Use closure

● Create a function that returns another function.


● The inner function should have access to the variables defined
in the outer function.
● Call the outer function and store the returned inner function in
a variable.
● Call the inner function and observe that it still has access to
the outer variables.
Task 9: Use immediately invoked function expressions (IIFE)

● Create an IIFE that performs a specific action immediately.


● Write an IIFE that logs a message to the console when the
page loads.

You might also like