Working variable to javascript. Need to format array properly