function getNum(stringCount) { var numCount = 0; for (var i = 0; i < stringCount.length; i++) { var char = stringCount.charAt(i); if (char != " " && !isNaN(char)) { numCount++; } } return numCount; } document.write(getNum("2022316yyyxy"));