0
One of my attempts so far has been:
array = [1, 2, 4, 5];
definir = function() {
switch (array) {
case (array > 1):
array.push(1);
break;
case (array > 2):
array.push(2);
break;
case (array > 0):
array.push(3);
break;
}
// Comparar elementos duplicado dentro de um vetor
var checar = array.filter(function(valor, i) {
return array.indexOf(valor) == i;
})
alert(checar);
}
<button onclick="definir();">Definir e Verificar</button>
I am looking to include new elements that are within an option case
in the array
.
But first check whether in the array
the same element is found to avoid duplicating!
Why You Need the Switch?
– Thiago Santos
@Thiagosantos Experiment in a personal project, nothing more.
– Diego Henrique