Advertisement
bebo231312312321

Untitled

Mar 4th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function oddOccurrences(input) {
  2.  
  3.     let result = {}
  4.     let resultWord = ""
  5.     let words = input.split(" ")
  6.         .map(word => word.toLowerCase())
  7.         .forEach(element => {
  8.             if (result[element] == undefined) {
  9.                 result[element] = 1
  10.             }
  11.             result[element]++
  12.         });
  13.  
  14.     for (let word in result) {
  15.         if (result[word] % 2 !== 1) {
  16.             resultWord += `${word} `
  17.             delete result[word]
  18.         }
  19.      
  20.     }
  21.  
  22.  
  23.     console.log(resultWord)
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement