-2
Come on, guys, good afternoon.
I’m doing a function that has the same utility as ANY
.
What is the idea, is to know if it has any number smaller than the given in the function inside the array, regardless of whether it is at the first or last position of the array.
If exister returns TRUE
, if not, return FALSE
The code is like this:
const numerosFora = [1];
function qualquer (num1, func){
for(let i = 0; i < num1.length; i++){
for(let i = 0; i < func.length; i++){
if(num1[i] < func[i]){
return true
} else {
return false
}
}
}
}
console.log(qualquer([1,0],numerosFora))
However it returns only if the number is in the first position, in case 0.
The question is not clear and I did not understand the code properly either. Why does not use any?
– BrTkCa
@Lucascosta Fala Lucas, good afternoon. The idea is for me to create my own Any, got it?
any
, got it? I want to know how I move from one element to the other in the array. EXAMPLE: Knowing if there is a number 3 in the array: Array = [1,2,3,4] I want to know how to go through 3 and return true, got it? And if it returns false, it goes next, until the last, got it? In mine, it goes to only the first and returns.– Jota
Starts the error that you have 2 nested loops using the same variable "i", should be two different variables, no?
– epx