Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function printInfo(...input) {
- function printSortedObject() {
- Object.entries(obj)
- .sort((a, b) => b[1] - a[1])
- .forEach((el) => output.push(`${el[0]} = ${el[1]}`));
- }
- function createObject() {
- input.forEach((el) => {
- let type;
- if (typeof el === 'object' && Object.values(el).length) {
- type = typeof el;
- output.push(`${type}:`);
- Object.values(el).forEach((e) => {
- fillObjectData(typeof e);
- });
- } else {
- type = typeof el;
- output.push(`${type}: ${el}`);
- fillObjectData(type);
- }
- });
- }
- function fillObjectData(type) {
- if (!obj[type]) {
- obj[type] = 0;
- }
- obj[type]++;
- }
- const obj = {};
- const output = [];
- createObject();
- printSortedObject();
- output.forEach((e) => console.log(e));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement