如何使用ES6方法对结果"cat“、”鼠标“进行控制台记录?
这是我的当前代码,当我使用console.log(collectionAnimals)时,它无法工作。
function collectAnimals(...animalList) {
return animalList;
}
collectAnimals("cat", "mouse");
console.log(collectAnimals)
发布于 2022-08-29 06:11:26
您需要将这些值存储在变量中。
在这一行中:
collectAnimals("cat", "mouse");因此,一旦该行执行由此生成或创建的数据,您就不会将其存储在任何地方。
所以,将它存储在这样的变量中
let x = collectAnimals("cat", "mouse");
console.log(x);然后打印"x“
https://stackoverflow.com/questions/73524681
复制相似问题