var numberArray = [1,2,3,4, 5,6,7,8,9, 9, 4];
var newArray = [];
function primeChecker(arrayCheck){
    for (var i = 0; i < arrayCheck.length; i++){
        if (Math.sqrt(arrayCheck[i]) % 1 === 0) {
            newArray.push(arrayCheck[i]);
        }
    }
    for (var x = 0; x < newArray.length; x++){
         newArray.sort();
        if (newArray[x] === newArray[x -1]){
            newArray.splice(newArray[x-1]);
        }
    }
}
primeChecker(numberArray);
console.log(newArray);
The returned array is [ 1, 4, 4, 9 ]. The function successfully gets rid of the repeating 9s but I am still left with two 4s. Any thoughts as to why this might be? I am a JavaScript beginner and not totally familiar with the language.
 
     
     
    