JSFiddle - React, Tailwind, and code Playground

by Vignesh Gopalakrishnan

HTML

<input type="button" class="btn" value="1" id="one" onclick="calculate('1')">
<input type="button" class="btn" value="2" id="two" onclick="calculate('2')">
<input type="button" class="btn" value="+" id="plus" onclick="calculate('+')">
<input type="textbox" id="val">

JavaScript

function calculate(val){
	if(!isNaN(val) || val=="+"){
		document.getElementById('val').value += val;
	}