Ad
  • Custom User Avatar

    don't waste your time..

    I really don't want to be harsh but it may not be clear to those not in the know that this is a really really horrible solution.

    1. modifying the input, which is bad practice.
    2. while loop makes no sense.. a better terminal condition, if he is going to continue using splice and modifying the original data: while(data.length > 0). I'm going to assume that he just gave 25 so that his loop would iterate answers up to 25 bytes long.. his solution will always iterate at least 25 times, and for data with more than 25 bytes, his solution is not guaranteed to work.
    3. At this point, (for one of the test case scenarios that is only 4 bytes long) he has an array that has 21 empty arrays in it, and 4 arrays with the actual data. He is reversing ALL of these (21 of which are unnecessary), and then using array.concat to squash the empty arrays and reduce them into a single final array.
  • Custom User Avatar

    Use console.log(input); as the first line of your function and you'll see the problem.
    input === [] is not the way to check if input is an empty array.