jQuery jAM, Season 6

Exercise 9.3

Number Again

	 
var number = /^(\+|-|)(\d+(\. \d*)?|\.\d+)([eE](\+|-|)\d+)?$/;

["1", "-1", "+15", "1.55", ".5", "5.", "1.3e2", "1E-4",
 "1e+12"].forEach(function(s) {
  if (!number.test(s))
  console.log("Failed to match '" + s + "'");
});

["1a", "+-1", "1.2.3", "1+1", "1e4.5", ".5.", "1f5",
 "."].forEach(function(s) {
  if (number.test(s))
  console.log("Incorrectly accepted '" + s + "'");
});

	 
	

To open the JavaScript console, press F12 or on MAC press COMMAND-OPTION-I.