0

Create an array variable that stores the leangth of the 3 sides of the box using the function calArea.

i need to know the code urgently, i am very week in javascript.

23rd May 2018, 7:33 AM
Twinkle Bawa
Twinkle Bawa - avatar
3 ответов
+ 3
Hi Twinkle I think this is what you want. cuboid=[1,1,1] //w,l,h function calcArea (a){ let area=2*a[0]*a[1] + 2*a[1]*a[2] + 2*a[1]*a[2]; return area; } console.log(calcArea (cuboid));// 6 Good luck!
24th May 2018, 7:22 PM
Mike Choy
Mike Choy - avatar
+ 1
Array variable called cuboid, initialized with three numbers representing width, length, height. All set to value 1. we then define a function called calcArea, which takes an array as input argument. Inside the function, we address the width length and height using array notation. a[0] is width, a[1] is length,a[2] is height. we calculate the area as the formula inside the function, and return it. we then call the function inside console.log with our cuboid variable, which prints the answer // is a comment
26th May 2018, 6:30 AM
Mike Choy
Mike Choy - avatar
0
i dont understand java... 🤕 ..can u help me with that
26th May 2018, 3:19 AM
Twinkle Bawa
Twinkle Bawa - avatar