Subsequence And Subarray Javascript Error