0
I need to traverse an array in Javascript where I should search among the numbers of array the first number divisible by the number that the user will inform and that is non-zero. I tried to create a code, but it is not considering an integer value in the division.
function busca(array, numero)
{
for(i = 0; i < array.length; i++)
if(array[i] % numero && -! 0)
return array[i]
}
console.log(busca([0, 7, 4, 15, 18, 3, -1, 323, -5], 2))
In case when passing the number 2 should return the number 4 of the array, but it is returning the 7.
I edited your answer to execute the code. If you didn’t like it, no problem, you can remove.
– user60252