Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(input = []) {
- let map = new Map();
- for (let i = 0; i < input.length; i++) {
- let line = input[i].split(" - ");
- let garageNumber = +line[0];
- let str = line[1].replace(/:/g, " -");
- if (!map.has(garageNumber)) {
- map.set(garageNumber, []);
- map.get(garageNumber).push(str);
- } else {
- map.get(garageNumber).push(str);
- }
- }
- for (const entries of map) {
- console.log(`Garage № ${entries[0]}`);
- entries[1].forEach((el) => console.log(`--- ${el}`));
- }
- }
Add Comment
Please, Sign In to add comment