JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button"onclick="calcCharge(document.getElementById('text1').value)"/>
<input type="text" id="text1"/>

JavaScript

function calcCharge(value)
{

var hour=parseInt(value);
 var tot=0;
if (hour==1)
		 tot=1;
	else if (hour>1 && hour<=20)
{
		tot=1+(0.5*(hour-1));
}
	else
{
		tot=10;
}
	
	
	alert(tot);

}