我无法求出圆的面积........................................................ ...
const radius = [22, 32, 12, 33];
const calcArea = function (radius) {
const op = [];
for (let i of radius) {
op.push(Math.PI * radius * radius);
}
return op;
};
console.log( calcArea(radius));
您需要在
i
中使用 radius
而不是 for loop
。
const radius = [22, 32, 12, 33];
const calcArea = function(radius) {
const op = [];
for (let i of radius) {
op.push(Math.PI * i * i);
}
return op;
};
console.log(calcArea(radius));