I\'m trying to create a javascript function that can take a fraction input string such as \'3/2\' and convert it to decimal—either as a string \'1.5\'
\'3/2\'
\'1.5\'
safer eval() according to MDN
const safeEval = (str) => { return Function('"use strict";return (' + str + ")")(); } safeEval("1 1/2") // 1.5
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Do_not_ever_use_eval!