//separate repeated characters and unique characters from an array.
const input = [3,5,3,2,4,6,3,5,6,7,3,5]
// output-
// [2,4,7]
// [3,5,6]
const extract = (arr) => {
const obj3 = {}
for(value of arr){
obj3[value] = (obj3[value] || 0) + 1
}
const uniqueElem = []
const repeatedElem = []
for(const [key, value] of Object.entries(obj3)){
console.log(value)
if(value ==1){
uniqueElem.push(key)
}else{
repeatedElem.push(key)
}
}
return {uniqueElem, repeatedElem}
}
console.log(extract(input))
To embed this project on your website, copy the following code and paste it into your website's HTML: