I'm populating a container with different symbols using an icon font. I want to know if there is a better way to iterate through hexadecimal values than to create a custom array and do it like this:
var hexPlaceValue1=0, hexPlaceValue2=0;
var hexArray = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
for(var i=0;i through something;i++){
if(hexPlaceValue1 == 15) {
var $glyph = $('<div class="glyph" data-glyph-index="' + i + '">' + String('00' + hexArray[hexPlaceValue2] + hexArray[hexPlaceValue1]).slice(-3) + ';</div>');
hexPlaceValue1 = 0;
hexPlaceValue2++;
} else {
var $glyph = $('<div class="glyph" data-glyph-index="' + i + '">' + String('00' + hexArray[hexPlaceValue2] + hexArray[hexPlaceValue1]).slice(-3) + ';</div>');
hexPlaceValue1++;
}
}
Obviously, this can lead to problems if more icons are introduced (granted, it would have to be a lot.) I just want to know if there is an more efficient way of doing this.