javascript check if a string is a positive integer

Return true if the string starts with or without the plus sign + and followed by a number from 1 to 9 and ends with a digit, else return false.

function isPositiveInteger(s) {
  return /^\+?[1-9][\d]*$/.test(s);

Search within Codexpedia

Custom Search

Search the entire web

Custom Search