const getAverage = (numberOne, numberTwo) => {
const average = (numberOne + numberTwo) / 2 ;
console.log(average);
};
getAverage(365, 27);
// Output: 196
const getAverage = (numberOne, numberTwo) => {
const average = (numberOne + numberTwo) / 2 ;
return average;
};
getAverage(365, 27);
// Output: SyntaxError: Identifier 'getAverage' has already been declared
at <anonymous>:1:1
为什么?
答案 0 :(得分:0)
如果这些功能位于同一位置,那么您的问题是您使用相同的功能名称。
const getAverage = (numberOne, numberTwo) => {
const average = (numberOne + numberTwo) / 2 ;
console.log(average);
};
getAverage(365, 27);
const getAverage2 = (numberOne, numberTwo) => {
const average = (numberOne + numberTwo) / 2 ;
return average;
};
console.log(getAverage2(365, 27));
&#13;