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

Java Script Assignment

The document outlines three programming tasks involving HTML, JavaScript, and data manipulation. Task 1 requires creating a web page with an input box and button that greets the user, utilizing arrow functions and higher-order functions. Task 2 involves using array methods to manipulate user data, while Task 3 focuses on building an app that fetches and displays data from an API with error handling and async/await functionality.

Uploaded by

samulakavyareddy
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)
5 views2 pages

Java Script Assignment

The document outlines three programming tasks involving HTML, JavaScript, and data manipulation. Task 1 requires creating a web page with an input box and button that greets the user, utilizing arrow functions and higher-order functions. Task 2 involves using array methods to manipulate user data, while Task 3 focuses on building an app that fetches and displays data from an API with error handling and async/await functionality.

Uploaded by

samulakavyareddy
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

Question 1:

Create a simple HTML + JavaScript page that:

Has an input box and a button saying “Greet Me”.

When the button is clicked, it should display a greeting message (Hello, <name>!) below
the button using template literals.

Use let/const appropriately (no var).

Write the event handler as an arrow function.

Add a higher-order function that takes a function as input (for example, a wrapper
function that logs the time whenever a function is executed). Use it to wrap the event
handler.

Question. 2:
You are given the following dummy data of users:

const users = [

{ id: 1, name: "Alice", age: 24, skills: ["JS", "React"] },

{ id: 2, name: "Bob", age: 30, skills: ["Java", "Spring"] },

{ id: 3, name: "Charlie", age: 28, skills: ["Python", "Django", "React"] },

];

Tasks:

Use array methods (map, filter, reduce) to:

List all users who know React.

Create an array of just user names.

Find the average age of users.

Use object & array destructuring to extract user details.

Add a new user object using the spread operator without mutating the original array.

Create a function that accepts ...skills as rest parameters and logs them.
Question.3:
Build a small app that fetches dummy data and displays it.

Create two JS files ([Link] and [Link]).

In [Link], write a function fetchPosts that uses fetch with async/await to get posts from:

👉 [Link]

and export it using ES modules (export).

In [Link], import fetchPosts and use it.

Display the first 5 post titles inside an HTML list (<ul>).

Add a loading message (Loading...) that disappears once the data is fetched.

Handle errors using try...catch.

Write a small demo (in console) to explain how the event loop handles async/await in
your code.

You might also like