Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let dictionary = objectMerging();
- for (let key in dictionary) {
- console.log(`Term: ${key} => Definition: ${dictionary[key]}`);
- }
- function sorting(input) {
- let arr = input;
- let pattern = /{"|":/g;
- arr.sort((a, b) => a.split(pattern)[1].localeCompare(b.split(pattern)[1]));
- return arr;
- }
- function jsToObjParsing() {
- let arr = sorting(input);
- arr = arr.map(el => JSON.parse(el));
- return arr;
- }
- function objectMerging() {
- let arr = jsToObjParsing();
- let targetObj = {};
- for (let el of arr) {
- Object.assign(targetObj, el);
- }
- return targetObj;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement