Advertisement
ErolKZ

Untitled

Dec 18th, 2021
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. function solve(input) {
  3.  
  4.  
  5. let dictionary = objectMerging();
  6.  
  7. for (let key in dictionary) {
  8.  
  9. console.log(`Term: ${key} => Definition: ${dictionary[key]}`);
  10.  
  11. }
  12.  
  13. function sorting(input) {
  14.  
  15. let arr = input;
  16.  
  17. let pattern = /{"|":/g;
  18.  
  19. arr.sort((a, b) => a.split(pattern)[1].localeCompare(b.split(pattern)[1]));
  20.  
  21. return arr;
  22.  
  23. }
  24.  
  25.  
  26. function jsToObjParsing() {
  27.  
  28. let arr = sorting(input);
  29.  
  30. arr = arr.map(el => JSON.parse(el));
  31.  
  32. return arr;
  33.  
  34. }
  35.  
  36.  
  37. function objectMerging() {
  38.  
  39. let arr = jsToObjParsing();
  40.  
  41. let targetObj = {};
  42.  
  43. for (let el of arr) {
  44.  
  45. Object.assign(targetObj, el);
  46.  
  47. }
  48.  
  49. return targetObj;
  50.  
  51. }
  52.  
  53.  
  54.  
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement