JSFiddle - React, Tailwind, and code Playground

by Michael Darmanin

HTML

<div id="choice">
    
</div>

<div id="hidden">

</div>

CSS

#hidden {
    display: none;
}

JavaScript

function add(x, y) {

	var filterFloat = function (value) {
      if(/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/
        .test(value))
        return Number(value);
    return NaN;
  }
  
	if (typeof x == 'string') {
  	filterFloat(x);
    console.log(x);
  }; 
  if (typeof y == 'string') {
  	filterFloat(y);
    console.log(y);
  };
  
  var z = filterFloat(x) + filterFloat(y);
  //var short = z.toFixed(4);
  //console.log(short);
  //return short.toString();
  //return z.toString();
  return z;
  var zz = z.toString();
  return zz;
  //console.log(typeof zz);
  
}


document.getElementById('choice').innerHTML = add("1234567890.0987654321", "8765432109.9012345678");