PayPal buy button using their javascript

I want to implement PayPal onto a checkout page and it seems the easiest way is using their javascript code found here:

This works as expected with hard-coded price but I can’t seem to set the value from a variable. What’s the syntax I should be using?

Problem solved. This is what I was looking for:

value: dmx.parse('')


Thanks for this, had to adjust a little for using an SPA, so landed up with
value: dmx.parse('')