Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* eslint-disable no-unused-vars */
- const users = [
- {
- name: 'A',
- age: 20,
- isAdmin: false,
- },
- {
- name: 'B',
- age: 15,
- isAdmin: true,
- },
- {
- name: 'C',
- age: 35,
- isAdmin: false,
- },
- {
- name: 'D',
- age: 61,
- isAdmin: true,
- },
- {
- name: 'E',
- age: 61,
- isAdmin: true,
- },
- ]
- // 1) remove the age property
- // 2) add property isAdminUnder18 (boolean)
- // 3) add property isAdminUnder18: true only if (isAdmin === true && age < 18) - else leave the object unchanged
- // -----
- // 4) get only the users that are selected
- const selectedUserNames = ['B', 'C', 'D', 'E']
- // 5) get the sum of the ages of the admins that are selected
- // 6) if the sum from 5) is greater than 75 -> return it. else return an array of the ages
- // 7) same as 6) but return an array without duplicates ([15, 61] instead of [15, 61, 61])
- // 8) same as 6) but return an array of the selected admins instead of their ages
- // 9) same as 8) but return an array containing only admins with different ages (if there is already an admin of age 61, you cannot add another)
- // 10) groupBy age
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement