码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-10-12 13:03:19      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:call   nbsp   循环   for   console   led   and   inf   text   

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.

标签:call   nbsp   循环   for   console   led   and   inf   text   

原文地址:http://www.cnblogs.com/xzma/p/7655400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!