我没有使用 for of 循环获取圆的面积,接下来我该怎么做

问题描述 投票:0回答:1

op

我无法求出圆的面积........................................................ ...

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));

javascript area for-of-loop
1个回答
0
投票

您需要在

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));

© www.soinside.com 2019 - 2024. All rights reserved.