Actually it doesn't , numbers are alphabetically detected Possible solution: http://stackoverflow.com/questions/11980087/javascript-words-to-numbers