Equal Rational Numbers LeetCode solution in JavaScript
1var isRationalEqual = function (s, t) {2return calculate(s) === calculate(t);34function calculate(v) {5let start = v.split("(")[0] || v;6let newer = (v.split("(")[1] && v.split("(")[1].split(")")[0]) || "0";78start = start.includes(".") ? start : start + ".";9newer = newer.padEnd(100, newer);1011return parseFloat(start + newer);12}13};