Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(...data) {
- let map = [];
- data.forEach(v => {
- let current = `${typeof v}: ${v}`;
- map.push(current);
- });
- for (let mapKey of map) {
- console.log(mapKey);
- }
- let asd = {};
- data.forEach(v => {
- let current = v;
- if (!asd.hasOwnProperty(typeof current)) {
- asd[typeof current] = [];
- }
- asd[typeof current].push(current);
- });
- let keys = Object.keys(asd).sort((a, b) => asd[b].length - asd[a].length);
- for (let mapKey of keys) {
- console.log(`${mapKey} = ${asd[mapKey].length}`);
- }
- }
Add Comment
Please, Sign In to add comment