← All tools

VuToV-Mykola/goit-js-hw-05

Popularity 60 Updated Data & Databases

📌 GoIT Homework-JS #5: Practice with array methods (map, filter, toSorted, reduce) and arrow functions for processing user data

githubauto-collected

Installation

A directly usable install command is not verified yet. Check the project documentation or releases.

📸 Скріншот проекту

<!-- END:AUTOGEN --

My Achievements

My Certificates - Completed Sololearn Course:

SOLOLEARN

JavaScript Homework 05

Task 1. User Names

COMPLETE THIS TASK IN THE FILE task-1.js

Write an arrow function getUserNames(users) that accepts one parameter users — an array of user objects. The function should return an array of all user names (the name property) from the users array.

Take the code below and insert it after declaring your function to check the correctness of its work. The console will display the results of its calls.

console.log(
  getUserNames([
    {
      name: "Moore Hensley",
      email: "moorehensley@indexia.com",
      balance: 2811
    },
    {
      name: "Sharlene Bush",
      email: "sharlenebush@tubesys.com",
      balance: 3821
    },

name: "Ross Vazquez", email: "rossvazquez@xinware.com", balance: 3793 }, { name: "Elma Head", email: "elmahead@omatom.com", balance: 2278 }, { name: "Carey Barr", email: "careybarr@nurali.com", balance: 3951 }, { name: "Blackburn Dotson", email: "blackburndotson@furnigeer.com", balance: 1498 }, { name: "Sheree Anthony", email: "shereeanthony@kog.com", balance: 2764 }, ]) ); // ["Moore Hensley", "Sharlene Bush", "Ross Vazquez", "Elma Head", "Carey Barr", "Blackburn Dotson", "Sheree Anthony"]


Leave this code for mentor verification.

### Mentor Review Criteria

- Declared variable `getUserNames`
- The variable `getUserNames` is assigned an arrow function with parameter `(users)`
- The `map()` method is used to iterate over the `users` parameter
- Calling the function with the specified array of users returns the array `["Moore Hensley", "Sharlene Bush", "Ross Vazquez", "Elma Head", "Carey Barr", "Blackburn Dotson", "Sheree Anthony"]`
- Calling the function with random but valid arguments returns the correct value

## Task 2. Users with Friend

COMPLETE THIS TASK IN THE FILE task-2.js

Write an arrow function getUsersWithFriend(users, friendName) that accepts two parameters:

  • first parameter users — an array of user objects
  • second parameter friendName — the name of a friend to search for

The function should return an array of all users from the users array who have a friend with the name friendName. Each user's friends are stored in the friends property. If there are no users with such a friend, the function should return an empty array.

Tips: