【发布时间】:2019-11-17 23:33:48
【问题描述】:
const alphabets= {
first: ["a", "b", "c"],
second: ["d", "e", "f"],
third: ["g", "h"]
};
function trial(arr) {
for (let i = 0; i < arr.length; i++) {
const argh = `<li class = "text-warning">${i}<li>`;
return argh;
}
};
console.log(trial(alphabets.second));
我在用数字替换条件的函数之外尝试了相同的“for循环”,它工作正常。为什么在放入函数并在条件中使用参数时它只循环一次?
【问题讨论】:
标签: javascript for-loop function-parameter