Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oddOccurences(input) {
- let words = input.split(' ').map(a => a.toLowerCase());
- let extracted = [];
- for (let word of words) {
- if (countOdd(words, word)) {
- extracted.push(word);
- }
- }
- extracted = [...new Set(extracted)];
- console.log(extracted.join(' '));
- function countOdd(array, value) {
- var n = 0;
- for (i = 0; i < array.length; i++) {
- if (array[i] == value) { n++ }
- }
- return n % 2 === 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement