A simple javascript exercise