test

Benchmark created on


Setup

var str = 'This is a much, much longer string that will have a character at the end that will not pass the validation!';

Test runner

Ready to run.

Testing in
TestOps/sec
codepoint at
function isAlphaNumeric(text){
  if (text.length === 0) {
    return false;
  }
  for (let index = 0; index < text.length; index++) {
    const character = text.charCodeAt(index);
    const isDigit = character >= 48 && character <= 57;
    const isUpper = character >= 65 && character <= 90;
    const isLower = character >= 97 && character <= 122;
    if (!(isDigit || isUpper || isLower)) {
      return false;
    }
  }
  return true;
}

isAlphaNumeric(str);
ready
regex
function isAlphaNumeric(text) {
  return /^[A-Za-z0-9]+$/.test(text);
}

isAlphaNumeric(str);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.