var summation = function(num) {
if (num <= 0) {
console.log("number should be greater than 0");
} else {
return (num + summation(num - 1));
}
};
console.log(summation(5));
它給了我NaN的錯誤,但我想number.where我是會犯錯的總和?
@blex感謝,它的工作原理:) – sanket