using js array methods