While Loop Structure Javascript Array Functions