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.
3 Respuestas
+ 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!
+ 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
0
i dont understand java... 🤕 ..can u help me with that