JS for循环实现 My cats are called Bill, Jeff, Pete, Biggles, and Jasmin.

Posted https://blog.zlevai.com

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS for循环实现 My cats are called Bill, Jeff, Pete, Biggles, and Jasmin.相关的知识,希望对你有一定的参考价值。

var cats = [‘Bill‘, ‘Jeff‘, ‘Pete‘, ‘Biggles‘, ‘Jasmin‘];
var info = ‘My cats are called ‘;
for (var i = 0; i < cats.length; i++) {
  if (i === cats.length - 1) {
    info += ‘and ‘ + cats[i] + ‘.‘;
  } else {
    info += cats[i] + ‘, ‘;
  }

}
console.log(info)

 

以上是关于JS for循环实现 My cats are called Bill, Jeff, Pete, Biggles, and Jasmin.的主要内容,如果未能解决你的问题,请参考以下文章

'for' loop initial declarations are only allo

Node.js 等待循环中读取的所有文件

Node.js 等待循环中读取的所有文件

JS中for循环嵌套打印100以内3的倍数?

JS中如何解决for循环中的延迟执行问题

js for循环删除两个数组相同元素