Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ivan Tomicic
3,873 PointsI have hard time understanding challenge?
Can someone try to explain this question to me, I have really no idea what should I do
Write the code inside this mimic_array_sum() function. That code should add up all individual numbers in the array and return the sum. You’ll need to use a foreach command to loop through the argument array, a working variable to keep the running total, and a return command to send the sum back to the main code.
1 Answer
Alexander Carr
9,839 PointsThe idea is to create a function that does basically the same thing as the array_sum() function, which takes each element of the array that you pass to it as a parameter, and adds them all together, then returns the result. The method the challenge is asking you to use to accomplish that is to use a foreach loop to iterate through each element of the array, summing them together as you go, then finally, once you reach the end of the array, return the value of the sum.
Does that help at all? Was there anything specific you didn't understand that I can clarify for you?