This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var is2through9 = /[2-9]/; | |
var genElement = function(elm){ | |
var elementCount = 1; | |
var lastChar = elm[elm.length-1]; | |
if (is2through9.test(lastChar)){ | |
elementCount = lastChar; /* add coefficient */ | |
elm = elm.slice(0, -1); | |
} | |
return [elementCount, elm]; |