How do I take an ascii code and convert it into its character using JavaScript? I'm in a nested loop and need to label each loop 1A, 2A, 1B, 2B, etc, and I would like to avoid hard coding every character using if statements.
You can use String.fromCharCode()
String.fromCharCode(ascii_value)
This is plain Javascript by the way. If you want to use hex numbers, convert them to decimal by using parseInt().
parseInt("ff", 16)
For example, this snippet takes the hex number ff and returns the character ÿ:
String.fromCharCode(parseInt("ff", 16))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With