Advertisement
bebo231312312321

Untitled

Mar 4th, 2023
65
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.hasOwnProperty(element)){
  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. console.log(resultWord)
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement