Count Objects In Array Javascript Append Function In Prolog