Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oddOccurences(input) {
- let wordsMap = new Map;
- let wordsArr = input.split(" ");
- wordsArr = wordsArr.map(word => word.toLowerCase());
- wordsArr.forEach(word => {
- let count = 1;
- if (!wordsMap.has(word)) {
- wordsMap.set(word, count);
- }
- else {
- let currentQuantity = wordsMap.get(word);
- currentQuantity++;
- wordsMap.set(word, currentQuantity);
- }
- });
- let arr = [...wordsMap];
- let line = "";
- arr.forEach(element => {
- if (element[1] % 2 != 0) {
- line += element[0] + " ";
- }
- });
- console.log(line);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement