Is there a way to insert a JavaScript value into a LaTeX expression? I want to write mathematical expressions with LaTeX but have some numbers (and maybe even strings) change dynamically.

For example, if I have a slider that changes a variable from 1 to 100 in steps of 1, then a LaTeX expression needs to change from… say, ${tex `x^1`} to ${tex `x^100`} accordingly.