Function to parse floats optionally followed by %, more strict than parseFloat in javascript I'm not a Javascript expert, so please review this function for me. Also, it  could be that there is something in any of the library we're using in our project that can do something similar for me (angular, foundation, jquery, underscore), but I'm not too familiar yet with most of them.

// helper function, parses numeric input also ending with %
  /*
  [parseNumeric('123') === 123,
   parseNumeric('10 abc') === undefined
   parseNumeric('10.10%') === 10.1,
   parseNumeric(' 10.1000 ') === 10.1,
   parseNumeric('10. 01%' ) === undefined,
   parseNumeric('10.0 %') === 10] */
  function parseNumeric(number) {
    if (number === undefined || typeof(number) === 'number')  {
      return number;
    }

    // delete trailing zeros and whitespaces between number digits and %,
    // leaving % if present
    var numberString = number.trim().replace(/\.?0*\s*(\%)?$/g,'$1');

    var parsedNumber = parseFloat(number);
    if (isNaN(parsedNumber)) {
      return undefined;
    }

    var parsedNumberLength = (parsedNumber+'').length;

    if (numberString.length === parsedNumberLength) {
      return parsedNumber;
    }

    if (numberString.charAt(numberString.length - 1) === '%' &amp;&amp;
        (numberString.length - 1) === parsedNumberLength) {
      return parsedNumber;
    }

    return undefined;
  }
I think it's a bit too much code. If you are already using a regular expression, why not using it to do all the parsing for you?

function parseNumeric(number) {
    var num = number.trim();
    var reOut = /^([-+]?(\d+\.?\d*|\d*\.?\d+))\s*%?$/.exec(num);
    return reOut ? parseFloat(reOut[1]): undefined;
}