Javascript Replace Part Of Array With Rows