I am trying to make a function named **val()** whose code is given below :

```js
var antiString = function(obj) {
  return Function('"use strict";return (' + obj + ')')()
};

var val = function(str) {
  var calc = str.replace(/px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax/gm, '');
  var unit = str.replace(/-|\+|\*|0|1|2|3|4|5|6|7|8|9\//gm, '');
  var value = antiString(calc).toString() + unit;
  return value;
};

// Now usage :
console.log(
  val("30px/2"),  // => 15px
  val("60vh/3") // => 20vh
)

// But when :
console.log(
  val("30px + 20px"), // => 50px px
  val("100% - 100%"), // => 0% %
  val("100% / 50%"), // => 2% %
)
```

I am not understanding how to deal with these problems. So where to update my function such that the units never repeat but numbers can ? I assume it will be something like this :

```
  val("30px - 20px"); // => 10px
  val("30% / 30%"); // => 1
  val("50% + 30%"); // => 80%
  val("25vh - 25vh"); // => 0

```