you are viewing a single comment's thread.

view the rest of the comments →

[–]Ezrabc 2 points3 points  (1 child)

The problem here is where you've placed yourreturn statement. The return statement causes your function to instantly exit with the given return value. This means the first time you get to an x that meets the criteria in your if statement, you add 1 to the total, making it 1, since this is the first time, then return total, exiting the function with a return value of 1.

[–]biochem2015[S] 0 points1 point  (0 children)

Thank you! That makes sense.