Advertisement
Guest User

Untitled

a guest
Aug 28th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     // let arrCars = [];
  4.     let objCars = {};
  5.  
  6.     for (const line of input) {
  7.         const infoLine = line.split(' | ');
  8.         let brand = infoLine[0]
  9.         let model = infoLine[1]
  10.         let produced = Number(infoLine[2]);
  11.  
  12.         // arrCars.push({brand, model, produced});
  13.  
  14.         objCars.brand = brand;
  15.         objCars.model = model;
  16.         objCars.produced = produced;
  17.  
  18.  
  19.         for (const key in objCars) {
  20.             if (objCars.hasOwnProperty(key)) {
  21.                 const element = objCars[key];
  22.                 console.log(element)
  23.                
  24.             }
  25.         }
  26.     }
  27.  
  28.    
  29.  
  30. }
  31.  
  32. solve(['Audi | Q7 | 1000',
  33. 'Audi | Q6 | 100',
  34. 'BMW | X5 | 1000',
  35. 'BMW | X6 | 100',
  36. 'Citroen | C4 | 123',
  37. 'Citroen | C4 | 22',
  38. 'Volga | GAZ-24 | 1000000',
  39. 'Lada | Niva | 1000000',
  40. 'Lada | Jigula | 1000000',
  41. 'Citroen | C4 | 22',
  42. 'Citroen | C5 | 10']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement