Build JS object of states