Advertisement
TZinovieva

Make A Dictionary JS Fundamentals

Feb 25th, 2023
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function createDictionary(arr) {
  2.     let dictionary = {};
  3.  
  4.     arr.forEach(str => {
  5.       let obj = JSON.parse(str);
  6.  
  7.       for (let term in obj) {
  8.         dictionary[term] = obj[term];
  9.       }
  10.     });
  11.  
  12.     Object.keys(dictionary).sort().forEach(term => {
  13.       console.log(`Term: ${term} => Definition: ${dictionary[term]}`);
  14.     });
  15.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement