Advertisement
Guest User

Argument Info

a guest
May 7th, 2017
1,194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Solution
  2. function argumentInfo() {
  3. let map = new Map();
  4.  
  5. for (let arg of arguments) {
  6. let type = typeof(arg);
  7. if (!map.has(type)) {
  8. map.set(type, 0);
  9. }
  10. map.set(type, map.get(type)+1);
  11. console.log(`${type}: ${arg}`)
  12. }
  13.  
  14. // console.log([...map.entries()]);
  15.  
  16. [...map.entries()].sort((a,b) => b[1] - a[1])
  17. .forEach((elem) => console.log(`${elem[0]} = ${elem[1]}`))
  18. }
  19.  
  20. // Testing
  21. argumentInfo('cat', 42,function () { console.log('Hello world!')}, 45);
  22. console.log(`-`.repeat(40));
  23. argumentInfo( { name: 'bob'}, { name: 'pesho'}, 3.333, 9.999, 'dog');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement