假设我想搜索 tickers 数组并返回数组中以 S 开头的所有项目,然后将它们写入 sCompanies = []。
任何人都知道我如何使用 for 或 while 循环来解决这个问题?
// Iterate through this list of tickers to build your new array:
let tickers = ['A', 'SAS', 'SADS' 'ZUMZ'];
//console.log(tickers);
// Define your empty sCompanies array here:
//Maybe need to use const sComapnies = [] ?
let sCompanies = []
// Write your loop here:
for (i = 0; i < tickers.length; i++) {
console.log(tickers[i]);
}
// Define sLength here:
sLength = 'test';
/*
// These lines will log your new array and its length to the console:
console.log(sCompanies);
console.log(sLength);*/
holdtom
萧十郎
三国纷争
Helenr
相关分类