I'm new to coding and I've been searching for hours and haven't really found a definitive answer to my problem. A few suggestions have been close to what I want to achieve which I think has helped a little but still not getting the outcome I want.
I've been using codepen.io a lot for seeing an instant output to my code as opposed to jsfiddle, just because I prefer how it works.
This is the code in question:
var x;
var y;
var z;
var arrayFiller;
var betaArray = new Object(256);
betaArray[0] = 0 + " " + 0;
for(var i=1; i<256; i++)
{
x = i;
y = x % 16;
x = x / 16;
x = Math.floor(x);
z = x % 16;
x = i;
arrayFiller = z + "" + y + " ";
$(
function()
{
var hexDerp =
{
'0' : "0",
'1' : "1",
'2' : "2",
'3' : "3",
'4' : "4",
'5' : "5",
'6' : "6",
'7' : "7",
'8' : "8",
'9' : "9",
'10': "A",
'11': "B",
'12': "C",
'13': "D",
'14': "E",
'15': "F"
};
var hexDerp1 = /(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)/g;
var arrayFillerHex = arrayFiller.replace
(
hexDerp1,
function(s)
{
if(s in hexDerp)
{
return hexDerp[s];
}
}
);
}
);
betaArray[i] = arrayFiller;
document.write(betaArray[i]);
}
My apologies if it is poorly formatted, I find this to be the clearest method for myself. The bit that currently doesn't work is the function part which is an amalgamation of what I've found in order to replace the 10-15 with a-f.
There may be other ways of getting this inputted and outputted, but I want to keep this for what I am going to end up using this for.
tl;dr: what I wanted to do with this code, is get an array that is 256 elements large, and populate the elements with the hexadecimal version of the element number, to later be used in a unique alphabet that I am making.