Task of Challenge #12/54
Create a function that receives an array of numbers and returns an array containing only the positive numbers.
The array: [-65, 11, -5, 1, -19, 45, 19, 0, 1].
To accomplish our task, we create a function called
getPositives() and pass in our array.
Inside the body, we need to create a new array (
tempArray), to keep only the positives inside.
The next step is to loop over the already existing array and check if the element we are currently looking at is positive.
If so, add it to the newly created array of
Once, we are done with iterating, checking and adding, just return the array and print it to the console, and you are done!