JSFiddle - React, Tailwind, and code Playground
by BumbleB2na
JavaScript
var myArr = [1, 1, 2, 5, 5, 7, 8, 9, 9];
var newArr = myArr;
for(var h = 0; h < myArr.length; h++) {
var curItem = myArr[h];
var foundCount = 0;
// search array for item
for(var i = 0; i < myArr.length; i++) {
if (myArr[i] == myArr[h])
foundCount++;
}
if(foundCount > 1) {
// remove repeated item from new array
for(var j = 0; j < newArr.length; j++) {
if(newArr[j] == curItem) {
newArr.splice(j, 1);
j = j - 1;
}
}
}
}
alert(newArr.toString());