JavaScript/6kyu/Consecutive_strings.js
// consecutive strings : follow one after another without an interruption
consecutive strings : follow one after another without an interruption
consecutive strings : follow one after another without an interruption
function longestConsec(strarr, k) {
  if (strarr.length < k || k < 0) return "";
  let combos = [];
  let left = 0;
  let right = k;
  while (right < strarr.length + 1) {
    let combo = strarr.slice(left, right).join('');
    combos.push(combo)
    left++;
    right = left + k;
  }
  let longestLength = combos.reduce((a, b) => { return a.length > b.length ? a : b }).length;
  return combos.find((el) => {return el.length === longestLength});
}
function longestConsec ( strarr , k ) { if ( strarr . length < k || k < 0 ) return "" ; let combos = [ ] ; let left = 0 ; let right = k ; while ( right < strarr . length + 1 ) { let combo = strarr . slice ( left , right ) . join ( '' ) ; combos . push ( combo ) left ++ ; right = left + k ; } let longestLength = combos . reduce ( ( a , b ) => { return a . length > b . length ? a : b } ) . length ; return combos . find ( ( el ) => { return el . length === longestLength } ) ; }
consecutive strings : follow one after another without an interruption
consecutive strings : follow one after another without an interruption