+ 2

How do I return the sum of the positive numbers in my array?

Ruby sum of positive integers in an array https://code.sololearn.com/cwdWczggpue3/?ref=app

30th Jan 2022, 10:56 PM
hamish
4 Answers
+ 2
First, you're not calling your function Second, in line 8 you are selecting only the negatives Finally, use what Matthews says, in the return of your function.
30th Jan 2022, 11:33 PM
CGM
CGM - avatar
+ 1
hamish def is to define, to call you must write the name where you want it to be executed: https://www.sololearn.com/Course/Ruby/2721/?ref=app https://www.sololearn.com/Course/Ruby/2723/?ref=app
31st Jan 2022, 1:16 AM
CGM
CGM - avatar
0
Cristian Gabriel Mazzulla thanks for your help. How do I call the function is that just by adding def at the start?
31st Jan 2022, 12:46 AM
hamish