const arr = ["abc", "pqr", "abc", "xyz", "xyz"];
const frequency = arr.reduce((acc, item) => {
acc[item] = (acc[item] || 0) + 1;
return acc;
}, {});
console.log(frequency);
const arr = ["abc", "pqr", "abc", "xyz", "xyz"];
const frequency = arr.reduce((acc, item) => {
acc[item] = (acc[item] || 0) + 1;
return acc;
}, {});
console.log(frequency);
For further actions, you may consider blocking this person and/or reporting abuse
Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.
This Week In JavaScript -
Leapcell -
Snappy Tuts -
Leapcell -
Top comments (0)