Javascript to demonstrate array manipulation