georgiev955

06. Make a dictionary

Jun 26th, 2023
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(jsonArr) {
  2.     let obj = {};
  3.     for (const json of jsonArr) {
  4.         let term = JSON.parse(json);
  5.         for (const key of Object.keys(term)) {
  6.             obj[key] = term[key];
  7.         }
  8.     }
  9.     const sortedTerms = Object.keys(obj).sort();
  10.     for (const term of sortedTerms) {
  11.         console.log(`Term: ${term} => Definition: ${obj[term]}`);
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment