[Answered ]-Working with formulas in Django using Javascript

1👍

Yes you can do so but Executing JavaScript from a string is an enormous security risk.

// get value as string from your file
let formula = getFromFile() // 'x * 5 + y'
// get x and y from user
let x = getXFromUser() // 1
let y = getYFromUser() // 2

console.log(eval(formula)) // 7

Check out documentation for eval here.

Leave a comment