Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeADictionary(input) {
- let dictionary = {};
- for (let el of input) {
- let parsedInput = JSON.parse(el);
- let entries = Object.entries(parsedInput);
- let [term, definition] = entries[0];
- dictionary[term] = definition;
- }
- let sortedDictionary = Object.entries(dictionary).sort((a, b) => a[0].localeCompare(b[0]));
- sortedDictionary.forEach(a => console.log(`Term: ${a[0]} => Definition: ${a[1]}`));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement