While Loop Structure Javascript Substring Negative Feedback