JSFiddle - React, Tailwind, and code Playground

Testing calculations

by Yurii Predborskyi

HTML

<div id='wrapper'>
  <div id='container'>
  
  </div>
</div>

CSS

#wrapper {
  font-family: monospace;
  background-color: white;
}

JavaScript

function say(text) {
	document.getElementById('container').innerHTML += text + '<br>';
}

function getDeviation(params) {
    let {weight, co2} = params;
    let co2RefValue = 36.59079 + 0.08987 * (+weight);
    return ((+co2) - co2RefValue) / co2RefValue * 100;
}

let params = {
	weight: 5000,
  co2: 500
};

let dev = getDeviation(params);

say(JSON.stringify(params));
say(dev);