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!
Follow me on Instagram and don’t miss the latest Challenge!
Become a bullet proof developer and seek my coding adventures on Udemy
Don’t miss two of my most read Medium Articles
5 Methods that drastically shorten drastically your Code in C# 8.0 by @ArnoldAbrahamP1 https://t.co/UlTW3H7bD9— Kumpulin1 (@kumpulin1) May 5, 2021