【发布时间】:2019-08-06 19:03:14
【问题描述】:
我想用sentence 数组的奇偶索引 填充两个数组(sentences 和 links):
这是我尝试但没有成功的方法:
let link_sentence = ">60-1> don't you worry >6-2> I gonna make sure that >16-32> tomorrow is another great day"; //
let sentence = link_sentence.split(">")
let sentences= []
let links = []
for(let i = 0; i < sentence.length; i += 2) {
sentences.push(sentence[i]);
}
console.log(sentences)
预期的输出应该是:
//let links = ["60-1", "6-2", "16-32"];
//let sentences = ["don't you worry", "I gonna make sure that", "tommorow is another great day"];
【问题讨论】:
-
sentences看起来非常接近正确,而您甚至没有尝试计算links。 -
我不知道应该如何计算链接,是的,如果句子看起来不太接近正确,我永远不会寻求帮助
标签: javascript