題目連結
https://www.codewars.com/kata/56a5d994ac971f1ac500003e
解法
function longestConsec(strarr, k) {
if (k <= 0 || strarr.length === 0) {
return '';
}
let long = ''
for (let i = 0; i < strarr.length - k + 1; i++) {
const currString = strarr.slice(i, i + k).join('')
if (currString.length > long.length) {
long = currString
}
}
return long
}