Ok, I can't get this to work....
My plan is:
-Import the array
-for each element in the array
--if positive, add to the positiveElements array
-Return positiveElements array
export const positiveElements = (arr) => {
for (let i=0; i<arr.length ; i++) {
if (arr[i]>0) {
positiveElements.push(arr[i]);
}
}
return positiveElements;
}
But this doesn't run at all...
What's the deal with
export const positiveElements = (arr) => {
Does this add arr-array into the positiveElements constant? So that I should rather remove from the array the negative and zero elements? This seems difficult, because then the for-loop won't work, as the length gets shorter.
Any hints, please?