10 lines
287 B
JavaScript
10 lines
287 B
JavaScript
|
|
// 截取数组元素,拼接成字符串并返回
|
||
|
|
module.exports = (arr, start, end) => {
|
||
|
|
let newString = '';
|
||
|
|
arr.forEach((element, index) => {
|
||
|
|
if (index >= start && index <= end) {
|
||
|
|
newString = newString + element;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return newString;
|
||
|
|
};
|