vbotio - 3 months ago 33

Javascript Question

I have 2 variables with different values

`{{ timelineExpectedAmount }} //1.996.626,32`

and

`{{ customTimelineExpectedAmount }} //6.104,77`

I want to know, how can I calculate how many %

`customTimelineExpectedAmount`

`timelineExpectedAmount`

I tried this:

`{{ timelineExpectedAmount / 100 * customTimelineExpectedAmount }}`

any hint ? the expected result is

`0.30%`

Answer

Really more of a math question...

```
var perc = 6104.77 / 1996626.32 * 100;
console.log(perc); // 0.3057542585134308
```

**Or, in your case:**

```
{{ customTimelineExpectedAmount / timelineExpectedAmount * 100 }}
```

You may want to round the result.