【发布时间】:2020-02-22 15:31:20
【问题描述】:
我有字符串数组
const arr = ['some', 'word', 'anotherverylongword', 'word', 'yyy', 'u']
const joined = arr.join(';')
我想获取连接字符串长度不大于 10 的块数组
例如输出将是:
[
['some;word'], // joined string length not greater than 10
['anotherverylongword'], // string length greater than 10, so is separated
['word;yyy;u'] // joined string length is 10
]
【问题讨论】:
-
我不明白,
anotherverylongword会发生什么? -
@Wendelin 如果它的长度大于 10,它应该留在数组中
标签: javascript arrays string split chunks