ErolKZ

Untitled

Oct 30th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1.  
  2. function solve (input) {
  3.  
  4.  
  5. let obj = {};
  6.  
  7. for (let i = 0; i < input.length; i++) {
  8.  
  9. let curr = JSON.parse(input[i]);
  10.  
  11. // console.log(curr);
  12.  
  13. Object.assign(obj, curr);
  14.  
  15. }
  16.  
  17.  
  18. Object.entries(obj).sort((a, b) => a[0].localeCompare(b[0])).forEach(a => console.log(`Term: ${a[0]} => Definition: ${a[1]}`));
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25. solve (
  26.  
  27. [
  28.  
  29. '{"Coffee":"A hot drink made from the roasted and ground seeds (coffee beans) of a tropical shrub."}',
  30.  
  31. '{"Bus":"A large motor vehicle carrying passengers by road, typically one serving the public on a fixed route and for a fare."}',
  32.  
  33. '{"Boiler":"A fuel-burning apparatus or container for heating water."}',
  34.  
  35. '{"Tape":"A narrow strip of material, typically used to hold or fasten something."}',
  36.  
  37. '{"Microphone":"An instrument for converting sound waves into electrical energy variations which may then be amplified, transmitted, or recorded."}'
  38.  
  39. ]
  40.  
  41. );
Advertisement
Add Comment
Please, Sign In to add comment