Subsequence And Subarray In Javascript