Coder Social home page Coder Social logo

lab-w01d05-filter-and-reduce's Introduction

var employees = [ { name: 'Ghadz', status: 'full-time', weeklyPay: 600 }, { name: 'Jax', status: 'part-time', weeklyPay: 200 }, { name: 'Jars', status: 'full-time', weeklyPay: 250 }, { name: 'Trevs', status: 'part-time', weeklyPay: 500 }, { name: 'Sauron', status: 'full-time', weeklyPay: 5000 }, { name: 'Patty Pancakes', status: 'full-time', weeklyPay: 300 } ]

var yourPayments = [ 220, 350, 300, 280, 500 ]




Your lovely client, Ms. Crocker, has some more requests.  Use the above data structures to answer the next few problems:

1.  Betty can't remember which of her employees work full-time.  Using filter, create a new array of only the full-time employees.

2.  Some employees are ready to strike!  They claim that they are working full-time but only getting paid part-time rates. Using filter, create an array that only contains the employees that are both full-time and get paid less than 500.  

3.  Betty decisively hates making multiple payments to you so she wants to pay you up front.  All of it.  At once.  Right now.  Use reduce to create a variable called "paycheck" that is equal to the total of your payments.

4.  Betty wants to figure out how much she is paying the part-timers this week.  Use reduce to create a variable called "ptPay" that is equal to the sum of all the part-timers weekly payments.

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.