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 trialLucas Santos
19,315 PointsNot sure what im doing wrong stuck on task 3
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.
This is how I got to Task 3 :
<?php
function mimic_array_sum( $array ){
$count = 0;
foreach( $array as $total ){
$count = $count + $total;
}
return $count;
};
$palindromic_primes = array( 11, 757, 16361 );
echo mimic_array_sum( $palindromic_primes );
?>
And this what I think it wants to me do :
<?php
function mimic_array_sum( $array ){
$count = 0;
foreach( $array as $total ){
$count = $count + $total;
}
return $count;
};
$palindromic_primes = array( 11, 757, 16361 );
echo mimic_array_sum( $palindromic_primes );
mimic_array_sum( $palindromic_primes ) = $sum;
echo $sum;
?>
1 Answer
Lucas Santos
19,315 PointsNever mind I got it I just to change it to this:
$sum = mimic_array_sum( $palindromic_primes );
echo $sum;