Equal Rational Numbers LeetCode solution in JavaScript

1
var isRationalEqual = function (s, t) {
2
return calculate(s) === calculate(t);
3

4
function calculate(v) {
5
let start = v.split("(")[0] || v;
6
let newer = (v.split("(")[1] && v.split("(")[1].split(")")[0]) || "0";
7

8
start = start.includes(".") ? start : start + ".";
9
newer = newer.padEnd(100, newer);
10

11
return parseFloat(start + newer);
12
}
13
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0