Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- const towns = {};
- arr.forEach((el, index) => {
- if (index % 2 === 0) {
- if (!Object.prototype.hasOwnProperty.call(towns, el)) {
- towns[el] = 0;
- }
- towns[el] += Number(arr[index + 1]);
- }
- });
- console.log(JSON.stringify(towns));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement