WEEK FOUR
LESSON ONE: ES6 FEATURES: ARROW FUNCTIONS,
TEMPLATE LITERALS,AND DESTRUCTURING
Tasks:
Task 1: Define an arrow function that takes four arguments: date
of birth(DOB), year,name, and location. The function should
calculate the user’s age. Using template literal,dynamically
display the “Hello name(user’s name) from (location), your
current age is (age) and return the age.
Task 2: Define a “userBio” object with the following properties:
occupation, height, gender, and nationality. Using object
destructuring, get “gender” and “occupation” from the object.
Use template literals to make a statement that displays the
user’s gender and occupation. Call the function three times with
three different users.
Task 3: Create an array of objects of length 4. Each object
should have the following properties: firstName, lastName,
complexion, and occupation. Loop through the array, for each
item, display the user’s info in a separate div created
dynamically.
Task 4: Create an asynchronous function that fetches and
returns data from a free weather API. Use the data to
dynamically populate a simple UI. You are to use only three core
values from the weather API to populate your UI. The design of
the UI depends on the weather API you’d be using. Apply
try/catch in your algorithm. If the request is not successful,
display a failure message to the user. Make your UI responsive.
LESSON TWO: CLASSES AND INHERITANCE
Tasks:
Task 1: Create a class of car with the following fields: numSeats,
numbHeadLamps, fuelTankMaxLitre,
numbExhaustPipe,convertible(boolean), numbOfDoors,
numbOfEnginePlug(default to 4). Instantiate the class to create
different types of cars using your car class(at least for).
Task 2: Create a class of phone, using your intuition, add at
least the core five features of a phone as the core class fields.
Instantiate the phone class to create different types of phone at
least three.
Task 3: Create a dog class and add the following methods: bark,
walk,run,wiggleTail, and getAngry. Add the following fields:
breed, colour, size, tail. Instantiate the class to create at least
three different breeds. Develop a simple UI for dog with buttons
for bark,run,getAngry, wiggleTail. Add an event listener, on click,
call the method to display what the dog is doing to the user.
Task 4: Explore prototypal inheritance and find a concept of your
own to teach it to the class on the specified day.