function findSolution(target) {
// we didn't mentioned values of current and history then how can it
takes the values of current and history?
function find(current, history) {
if (current == target) {
return history;
} else if (current > target) {
return null;
} else {
return find(current + 5, `(${history} + 5)`) ||
find(current * 3, `(${history} * 3)`);
}
}
return find(1, "1");
}
console.log(findSolution(24));
// → (((1 * 3) + 5) * 3)
//请解释结果
答案 0 :(得分:0)
参数名称用于创建变量。这些值是在调用函数时定义的。
function find(current, history) { return find(1, "1");
current
是1
,而history
是"1"
(当在程序的其他部分中使用不同的参数调用它们时,它们将具有不同的值)。