I need a function that takes the ASCII value of a JavaScript character (or whatever type of variable compose a JavaScript string) and returns a string of its bit representation. The ???
in the following code needs filled in.
function bitstring(var thisUnsigned)
{
var retStr = "";
for (var i = 0; i < ???; i++)
{
retStr += thisUnsigned & 1 ? "1" : "0";
thisUnsigned >>= 1;
}
return retStr;
}
I've seen here How many bytes in a JavaScript string? that each character is 16 bits, but then again I know that an ASCII chart only has 127 characters in it.
Go easy on me. I'm on a JavaScript n00b. ;)