- Kod: Markera allt
* Exercise 2.1 (3 points)
*
* In this exercises you should use the former functions sumArray() and
* calculateArea(). Create a new function called calculateMany() that
* takes an array with numbers as argument. For every number in the array,
* call calculateArea() and store the result in a new array. The last
* position in your new array should hold the result of a call to the function
* calculateArea() where you pass the sum of the whole array, you passed as
* argument. All numbers in the resulting array should be rounded up to
* nearest integer. Loop through the array and convert all values to nearest
* higher integer value.
*
* Tip: intval().
* Note: If your result seems correct but still fails, make sure your values
* are of the type Integer and not Float.
*
* Answer with a call to calculateMany() with the array 39, 27, 29, 49, 7.
*
* Write your code below and put the answer into the variable ANSWER.
*/
function calculateMany($z) {
$newArray = array();
foreach ($z as $value) {
array_push($newArray, calculateArea($value));
}
array_push($newArray, calculateArea(array_sum($z)));
return $newArray;
}
$ANSWER = calculateMany([39, 27, 29, 49, 7]);
Är så nära jag måste få till den här.. Fixar inte till det med intval() bara, någon som ser var jag ska sätta den/dem för att få till det? Eller finns någon smartare lösning?