Advertisement
Guest User

MakeDictionary

a guest
Oct 28th, 2019
2,684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dictionary(input){
  2.     let dict = {};
  3.     for (let element of input){
  4.         let obj = JSON.parse(element);
  5.         dict = Object.assign(dict, obj);       
  6.     }
  7.        
  8.     let sortedKeys = Object.keys(dict);
  9.     sortedKeys.sort((a, b) => a.localeCompare(b));   
  10.      
  11.     for (let term of sortedKeys) {
  12.         let definition = dict[term];             
  13.         console.log(`Term: ${term} => Definition: ${definition}`);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement