问题描述
let sumOfSquareNum = (num) =>{
let S = (num(num + 1)(2*num + 1 )/6)
alert (`The result of sum of 50 is ${S} where input is ${num}` )
}
sumOfSquareNum(5)
解决方法
您需要在隐含的位置插入 *
否则您将得到一个 TypeError
,因为它由于缺少运算符而在语法上不正确。
const sumOfSquareNum = (num) => {
const S = (num * (num + 1) * (2 * num + 1) / 6)
alert(`The result of sum of 50 is ${S} where input is ${num}`)
}
sumOfSquareNum(5);