In this part of your code:
console.log(buscarDivisivelPor(numeros, 100))
You print the returned value of buscarDivisivelPor(numeros, 100).
But since you aren't returning anything in the last else clause, it will print undefined if no numbers match your criteria.
Additionally, the console.log in the else if clause of your function will print any value that is divisible by the number provided.
There is also an error in your logic: "Numbers divisible not found!" is printed when an element of the array is zero, because otherwise it would be caught by the first if or the second else if. See what happens if you use [0,0,0,0] as the input array.
You could fix all this by providing a default return value in case no divisible numbers are found:
var numeros = [0, 9, 4, 7, 128, 42, -1, 301, -5];
function buscarDivisivelPor(array, num) {
for (var i = 0; i < array.length; i++) {
if (array[i] % num != 0) {
continue;
} else if (array[i] % num == 0 && array[i] != 0) {
return array[i];
}
}
return "Numbers divisible not found!";
}
console.log(buscarDivisivelPor(numeros, 100));
// "Numbers divisible not found!"