update js word logic