JSFiddle - React, Tailwind, and code Playground
JavaScript
var x = '3';
if (typeof x != "String") {
str = x.toString();
(str.match(/([0-9]+[\.|,][0-9]*)|([0-9]*[\.|,][0-9]+)|([0-9]+)/)) ? alert('true') : alert('false');
} else {
(x.match(/([0-9]+[\.|,][0-9]*)|([0-9]*[\.|,][0-9]+)|([0-9]+)/)) ? alert('true') : alert('false');
}