logo CodeStepByStep logo

array_mystery0

Language/Type: PHP array mystery arrays

Consider the following function:

function array_mystery0($arr) {
    for ($i = 1; $i < count($arr); $i++) {
        $arr[$i] = $arr[$i] + $arr[$i - 1];
    }
    return $arr;
}

For each array below, indicate what the returned array's contents would be after the function array_mystery0 were called and passed that array as its parameter.

[8]
[6, 3]
[2, 4, 6]
[1, 2, 3, 4]
[7, 3, 2, 0, 5]

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.