Задача 6. Make a Dictionary (Objects and Classes) JavaScript
1.Make a Dictionary
You will receive an array with strings in the form of JSON's.
You have to parse these strings and combine them into one object. Every string from the array will hold terms and a description. If you receive the same term twice replace it with the new definition.
Print every term and definition in that dictionary on new line in format:
Term: ${term} => Definition: ${definition}
Don't forget to sort the dictionary alphabetically by the terms as in real dictionaries.
Examples
Input |
Output |
[ '{"Coffee":"A hot drink made from the roasted and ground seeds (coffee beans) of a tropical shrub."}', '{"Bus":"A large motor vehicle carrying passengers by road, typically one serving the public on a fixed route and for a fare."}', '{"Boiler":"A fuel-burning apparatus or container for heating water."}', '{"Tape":"A narrow strip of material, typically used to hold or fasten something."}', '{"Microphone":"An instrument for converting sound waves into electrical energy variations which may then be amplified, transmitted, or recorded."}' ] |
Term: Boiler => Definition: A fuel-burning apparatus or container for heating water. Term: Bus => Definition: A large motor vehicle carrying passengers by road, typically one serving the public on a fixed route and for a fare. Term: Coffee => Definition: A hot drink made from the roasted and ground seeds (coffee beans) of a tropical shrub. Term: Microphone => Definition: An instrument for converting sound waves into electrical energy variations which may then be amplified, transmitted, or recorded. Term: Tape => Definition: A narrow strip of material, typically used to hold or fasten something. |
Ето го моят код: https://pastebin.com/bK7rhV4b
Дава ми 80/100, защото просто не мога да измисля как да ъпдейтна ако думата се повтаря.
EDIT:
Успях да я реша, ето кода, ако може да помогне на някой https://pastebin.com/BwwvEEM1
Ако някой има по-опростени и интересни решения да сподели :)
Доста по изчистено и подредено:)
Благодаря!