bobo_bobkata

Untitled

Oct 8th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function solve(...data) {
  2. let map = [];
  3. data.forEach(v => {
  4. let current = `${typeof v}: ${v}`;
  5. map.push(current);
  6. });
  7. for (let mapKey of map) {
  8. console.log(mapKey);
  9. }
  10. let asd = {};
  11. data.forEach(v => {
  12. let current = v;
  13. if (!asd.hasOwnProperty(typeof current)) {
  14. asd[typeof current] = [];
  15. }
  16. asd[typeof current].push(current);
  17. });
  18. let keys = Object.keys(asd).sort((a, b) => asd[b].length - asd[a].length);
  19. for (let mapKey of keys) {
  20. console.log(`${mapKey} = ${asd[mapKey].length}`);
  21. }
  22. }
Add Comment
Please, Sign In to add comment