I am getting some numbers from the DOM, one originalPrice and one discountPrice. Now i wanna write out the % differens between the two. These numbers can alway vary. So my question:
Can i calculate variables? For exaple:
((originalPrice - discountPrice) / originalPrice) * 100;
and then use Math.round
to get rid of decimals?
When i try it i only get NaN
This is what i have tried:
var originalPrice = document.querySelector('.original-price')
var discountPrice = document.querySelector('.from-price')
Math.round((originalPrice - discountPrice) / originalPrice) * 100;
I only get NaN
. I expect differens in %