Suppose a string like this 1.2-1.4
. What I want is to split this string at -, then multiply each of the parts by a factor, and finally return a string like part1*factor-part2*factor
.
Ie. if the string is declared like this: var range = '1.2-1.4';
, and factor is declared like this: var factor = 10;
, I would like get a string like 12-14
.
So I did the following so far:
var range = '1.2-1.4';
var factor = '10';
let complex = '';
const parts = range.split("-");
parts.forEach(function(element){
// what is the shortest code that would concat the parts in the way I want?
});
TIA.