JSFiddle - React, Tailwind, and code Playground
by Lexogram
JavaScript
var num = 1e3;
var str = "1e3";
var regex = /^[0-9]{3,7}$/;
alert( "typeof " + num + ": " + typeof num);
alert( "typeof " + str + ": " + typeof str);
if (typeof num === "string") {
alert ("Match if num is already a string: " + str.match(regex));
} else if (typeof num === "number") {
str = num.toString();
alert ("Match when num is converted to string: " + str.match(regex));
}