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.的主要内容,如果未能解决你的问题,请参考以下文章