Advertisement
finalmail

Untitled

Nov 12th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* eslint-disable no-unused-vars */
  2. const users = [
  3.     {
  4.         name: 'A',
  5.         age: 20,
  6.         isAdmin: false,
  7.     },
  8.     {
  9.         name: 'B',
  10.         age: 15,
  11.         isAdmin: true,
  12.     },
  13.     {
  14.         name: 'C',
  15.         age: 35,
  16.         isAdmin: false,
  17.     },
  18.     {
  19.         name: 'D',
  20.         age: 61,
  21.         isAdmin: true,
  22.     },
  23.     {
  24.         name: 'E',
  25.         age: 61,
  26.         isAdmin: true,
  27.     },
  28. ]
  29.  
  30. // 1) remove the age property
  31.  
  32. // 2) add property isAdminUnder18 (boolean)
  33.  
  34. // 3) add property isAdminUnder18: true only if (isAdmin === true && age < 18) - else leave the object unchanged
  35. // -----
  36.  
  37. // 4) get only the users that are selected
  38. const selectedUserNames = ['B', 'C', 'D', 'E']
  39.  
  40. // 5) get the sum of the ages of the admins that are selected
  41.  
  42. // 6) if the sum from 5) is greater than 75 -> return it. else return an array of the ages
  43.  
  44. // 7) same as 6) but return an array without duplicates ([15, 61] instead of [15, 61, 61])
  45.  
  46. // 8) same as 6) but return an array of the selected admins instead of their ages
  47.  
  48. // 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)
  49.  
  50. // 10) groupBy age
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement