Contact: aviboots(AT)netvision.net.il
39,990 questions
51,935 answers
573 users
function hasOnlyDigits(str : string) { return str.match(/^[0-9]+$/) != null } console.log(hasOnlyDigits("typescript")); console.log(hasOnlyDigits("typescript 2024")); console.log(hasOnlyDigits("948238")); /* run: false false true */
function hasOnlyDigits(str : string) { return /^\d+$/.test(str); } console.log(hasOnlyDigits("typescript")); console.log(hasOnlyDigits("typescript 2024")); console.log(hasOnlyDigits("1092834")); /* run: false false true */