While Loop Structure Javascript Substring Negative Reinforcement