function render(model){ function addImage() { if (model.active_states[0].image_url) { return $("img", {src: model.active_states[0].image_url, style: {height: "70%", margin: "0 auto"}}) } else { return "No image available." } } return <div style={{textAlign: "center"}}> <h1>{model.active_states[0].name}</h1> {addImage()} </div>; }