Ad
  • Custom User Avatar

    I'm looking for some pointers on making this more efficient. It's failing due to it taking too long to execute the 5500+ tests that this Kata runs.

    function transposeTwoStrings(arr) {
    var twoStrings = '';
    var string1 = arr[0];
    var string2 = arr[1];
    var longestString = arr.sort(function(a, b) {
    return b.length - a.length;
    })[0].length;

    for (i = 0; i < longestString; i++) {
    twoStrings += (string1[i] || ' ') + ' ' + (string2[i] || ' ') + '\n';
    }
    return twoStrings.slice(0, -1);
    }