Reputation: 385
I have a list of ascii character codes returned as '104,101,108,108,111', and I am trying to translate those back to a string:
response = '104,101,108,108,111'
String.fromCharCode(response)
When I pass this to String.fromCharCode(response)
then I get ' '
as response, but when I pass input like below I am able to get proper response:
String.fromCharCode(104,101,108,108,111)
How can we pass number codes if we have a string of codes as response?
Upvotes: 0
Views: 141
Reputation: 349873
You need to turn your string into separate arguments: split by comma and spread:
let response = '104,101,108,108,111';
let result = String.fromCharCode(...response.split(","));
console.log(result);
Upvotes: 3