JSFiddle - React, Tailwind, and code Playground
by f0t0n
HTML
<textarea name="cls" id="cls" cols="60" rows="10" readonly></textarea>
CSS
#cls {
border: 1px solid #ddd;
border-radius: 5px;
resize: none;
color: #444;
}
JavaScript
(function() {
var g,
time,
distance,
result,
getDistance;
g = 9.832; // m per square second
/**
* Retrives a distance
* the object will fall in given time.
*
* @time - time in seconds
*/
getDistance = function(time) {
return Math.pow(time, 2) * g / 2; // h = g * t^2 / 2
};
time = 60; // 60 s
distance = getDistance(60);
result = "A height of fall during the time of "
+ time + "s \nis "
+ distance.toFixed(2) + "m "
+ "(~ " + (distance / 1000).toFixed(2) + "km).";
document.getElementById("cls").value = result;
})();