Count Objects In Array Javascript Append To Beginning