While Loop Array Javascript Append Function In Prolog