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 trialCortney Burgess
10,758 Pointswhat am i doing wrong?
In the main code, outside of the function, use the new mimic_array_sum() function you just wrote. Store the return value in a variable called $sum, and then display that sum to the screen.
function mimic_array_sum($array) {
$sum = 0;
foreach($array as $element) {
$sum = $sum + $element;
}
return $sum;
}
$palindromic_primes = array(11, 757, 16361);
$sum = mimic_array_sum($palindrominc_primes);
echo $sum;
?>```
3 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Cortney,
Check your spelling on the primes variable.
Cortney Burgess
10,758 Pointsokay thank you.
Jeff Busch
19,287 PointsHi Cortney,
I really really hate it when that happens. Look at the code below: SPELLING. In fact when I pasted the code below the browser picked up the spelling error.
Jeff
$palindromic_primes = array(11, 757, 16361);
$sum = mimic_array_sum($palindrominc_primes);