Javascript Replace Part Of Array With Repeated