0% found this document useful (0 votes)
0 views2 pages

Assignemnt 3 (ES6)

The document outlines an assignment for an Emerging Technology Lab focusing on ES6, callback and higher-order functions, and array methods. It includes tasks such as creating functions for palindrome checks, calculating factorials, using setTimeout and setInterval, manipulating arrays of car brands and product objects, and defining a Person class with specific properties and methods. Each task emphasizes the use of modern JavaScript features and array operations to achieve the desired outcomes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

Assignemnt 3 (ES6)

The document outlines an assignment for an Emerging Technology Lab focusing on ES6, callback and higher-order functions, and array methods. It includes tasks such as creating functions for palindrome checks, calculating factorials, using setTimeout and setInterval, manipulating arrays of car brands and product objects, and defining a Person class with specific properties and methods. Each task emphasizes the use of modern JavaScript features and array operations to achieve the desired outcomes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Emerging Technology Lab

Assignment 3
ES6, Callback & Higher-Order Functions, Array Methods
1. Write an arrow function that will check if a given number is palindrome or not. If palindrome
the function will return true and false otherwise. Call the function and display messages
accordingly.
2. Write a lambda expression to find xy.
3. Create a calculateFactorial function that takes a number and a callback function. The
calculateFactorial calculates the factorial and the callback function should display the factorial
value.
4. Answer the following questions using setTimeout, setInterval and clearInterval.
a. Create a function delayedGreeting that accepts a name and a delay time (in
milliseconds). After the specified delay, it should log a greeting message (e.g., "Hello,
[name]!").
b. Display a 10 second count down timer in a webpage.
5. Consider an array of car brands:
carBrands = [ "Toyota", "Ford", "BMW", "Mercedes-Benz", "Honda", "Audi", "Tata", "Tesla",
"Mahindra", "Volkswagen" ];
a. Create a function which will take an array and display the array elements. Use this to
display the array after each following operation.
b. Add one more car brand to the array
c. Remove the last car brand from the array.
d. Check if the array contains “Tata”.
e. Sort the cars in alphabetical order.
f. Make shallow copy of the array.
6. Construct an array of 10 numbers and perform the following operations using higher-order
array methods –
a. Display the array elements using forEach
b. Produce a new array by squaring each number of the given array using map
c. Produce an array with all the even numbers present on the original array using filter
d. Remove any number from the array using filter
e. Sort the array in both ascending and descending order using sort and display
f. Find the average of the array elements
g. Find the smallest number amongst the array elements.
7. Given an array of product objects, where each object contains the name and price of a
product. Answer the following questions using higher order array methods.
a. Use forEach loop, object de-structuring, and string literals to display the details in the
given format – “A laptop costs Rs 50000 and has a rating of 4.7”.
b. Create a List of Product Names
c. Create an array of all the Electronics products and display the array
d. Find the Product with the Highest Price
e. Find the average rating of all the products
f. Get Products That Are Priced Below 10000
products = [
{ name: "Smartphone", price: 15000, rating: 4.5, category: ["Electronics", "Mobile", "Gadget"] },
{ name: "Laptop", price: 50000, rating: 4.7, category: ["Electronics", "Computer", "Gadget"] },
{ name: "Headphones", price: 2000, rating: 4.0, category: ["Electronics", "Accessories"] },
{ name: "Shoes", price: 3000, rating: 4.3, category: ["Fashion", "Footwear"] },
{ name: "Watch", price: 3500, rating: 4.2, category: ["Fashion", "Accessories"] },
{ name: "Washing Machine", price: 25000, rating: 4.6, category: ["Home Appliances", "Electronics"] },
{ name: "Refrigerator", price: 35000, rating: 4.4, category: ["Home Appliances", "Electronics"] },
{ name: "Table Lamp", price: 1000, rating: 3.8, category: ["Home Decor", "Furniture"] },
];

8. Write a Person class with the following properties: firstName, lastName, and age. Include a
method getFullName() that returns the full name of the person. Use constructor to initialize
the data member and another function getDetails() to display all the details.

You might also like