小编Cod*_*yes的帖子

如何 console.log 数组中的每个元素?

我在解决与 forEach 方法相关的问题时遇到了麻烦。我已经尝试了所有我能想到的编写这段代码的方法,但问题一每次仍然是错误的。

function exerciseOne(names){

// Exercise One: In this exercise you will be given and array called names. 

// Using the forEach method and a callback as it's only argument, console log

// each of the names.
}


// MY CODE: 

function logNames(name){

  console.log(name);
}

 names.forEach(logNames);
Run Code Online (Sandbox Code Playgroud)

javascript arrays

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

arrays ×1

javascript ×1