How to remove last element from array in javascript