JSFiddle - React, Tailwind, and code Playground

by Pradeep Shankar

HTML

<input type="text" id="num" />
<button id="doround">Round</button>
<div id="rounded">
</div>

CSS

#rounded { font-size: 20px; background: cyan; }

JavaScript

var round = function (a, x, to) {
    return (a + Math.ceil(x / to) * to);
};

$('#doround').click(function () {
    var value=$('#num').val();
    $('#rounded').text(round(Math.floor(value), value % 1, .05));
});