Is there a way to prevent duplicate entries in an array of doubles like [1, 2, 2, 3, 1] when checking its contents?
function checkDuplicates() {
entered_values = document.getElementById('values').value;
values_array = entered_values.split(',');
if($.trim(entered_values) != ''){
//location.href = base_url + 'values/' + encodeURIComponent(entered_values);
}
if (localStorage.data_list){
data_list = JSON.parse(localStorage.getItem('data_list'));
$("#history").toggle();
} else {
data_list = [];
}
for (num in values_array){
console.log(localStorage.data_list);
data_list.push({'numbers':values_array[num]});
localStorage.setItem('data_list', JSON.stringify(data_list));
}
}