Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function garage (input){
- let cars = {}
- input.map(element =>{[carNum,carsInfo]= element.split(" - ")
- if(cars[carNum]=== undefined){
- cars[carNum] = []
- }
- cars[carNum].push(carsInfo)
- });
- let output = ""
- Object.entries(cars).sort((a,b) => a[0]-b[0]).forEach(([garage, cars])=> {
- output += `Garage β ${garage}\n`;
- for (let currCar of cars) {
- currCar = currCar.replace(/: /g, ' - ');
- output += `--- ${currCar}\n`
- }
- })
- console.log(output)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement