Advertisement
pharmokan

reduce and map

Apr 22nd, 2020
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. reduce is a counter
  2. returns number in the end
  3. occurrences
  4. starting ,0) carries/passes over into next iterative function as acc
  5. any math inside +equals the accumulator ( first argument)
  6.  
  7. const map = new Map();
  8. if (map.has(a)) counter += map.get(a);
  9. map.set(b, (map.get(b) || 0) + 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement