Dynamic Size Array Javascript Splice Function Of Array