Reputation: 3
I am making a piece of code to make a prompt appear with a user defined character. What I mean is, the user typed a dec or hex character value, and it will make a prompt appear with the character. This is my code:
var userChar = prompt("Type an ASCII hex or dec value");
alert("&#" + userChar + ";");
Let's say the user typed "220" for the character "Ü", instead of the alert displaying "Ü", it displays "Ü
" How do I make it display "Ü" instead of Ü
?
Upvotes: 0
Views: 94
Reputation: 4832
Use alert(String.fromCharCode(userChar))
to convert Ascii to string.
Upvotes: 1