Git Product home page Git Product logo

lab-js-es6-reinforcement_25062024's Introduction

logo_ironhack_blue 7

JS | ES6 - reinforcement

Introduction

For this exercise, you can use Repl.it or your code editor.

Using the array of users given in the data.js file, go ahead and finish the tasks as specified in the task list. You should have your solution saved in the index.js file.

Requirements

  • Fork this repo
  • Then clone this repo.

Submission

  • Upon completion, run the following commands:
$ git add .
$ git commit -m "done"
$ git push origin master
  • Create Pull Request so your TAs can check up your work.

Instructions

Iteration 1: for...of loop

Create a function getFirstNames() and, using for...of loop, iterate over the usersArray and push all the first names into a new array userFirstNames.

Iteration 2: for...of loop and ES6 string literals ${}

Create a function getFullNames() which will return an array of strings where each string will represent the full name of each user from the usersArray.

Steps:

  1. using for...of loop iterate over the usersArray and
  2. using ES6 string interpolation create a string containing full name (tip: access each object via dot notation),
  3. push that string into a new array userFullNames.

Iteration 3: ES6 destructuring, for of loop, object literal

Create a function getUsersCreditDetails() to grab each user's first and last name and their balance.

Steps:

  1. Using for...of loop iterate over the usersArray;
  2. Destructure firstName, lastName and balance from each user object to create new variables;
  3. After destructuring create a new object using object literal (only name of variable) consisting of firstName, lastName and balance. Check the following example:
const userDetails = {
  firstName,
  lastName,
  balance
};
  1. Push each new object into a new array usersCreditDetails

Iteration 4: practice .filter() method and how to return two elements

Create a function genderView() which should return two arrays new arrays femaleUsers and maleUsers. Depending on the gender, fill them with strings containing users' first and last names.

Bonus - Iteration 5

Create a function genderCount() that should use the returned object from the previous function and print how many females and how many male users there are.

Check the index.js to see what should be expected output.

Bonus - Iteration 6

Create a function promo20() to find all users whose balance is greater than 20000 and send them a personalized message offering some promotion.

Check the index.js to see what should be expected output.

Bonus - Iteration 7

Create a function addActive() which should loop through the usersArray and add a new property isActive with a value true to all users (hint: each user in the usersArray is represented with object and you could use ... with objects ๐Ÿ˜‰ ).

Check the index.js to see what should be expected output.

Happy coding! โค๏ธ

lab-js-es6-reinforcement_25062024's People

Contributors

sandrabosk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.