How to Remove and Add Elements to a JavaScript Array