Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
JS function of representing array elements in ASCII

function translateInWord(mas){
  mas = [].concat(...mas);
  for (let i = 0; i < mas.length; i++){
    mas[i] = String.fromCharCode(mas[i]);
  }
  return mas;
}
console.log(translateInWord([[6,8,13],[5,3,0]]));

I want the program to show me every letter in ASCII from the array 'mas` (that is, it should turn out ['G','I','N','F','D','A'])

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using a 0-indexed representation of the alphabet (0 -> A, ..., 25 -> Z).

fromCharCode() is taking UTF-16 code units as parameters.

If you look at an UTF-16 table, the decimal representation of A is 65 and the following 25 code units are corresponding to the other capital letters of the alphabet up to Z.

So you just need to add 65 to mas[i] to get its corresponding letter :

function translateInWord(mas){
  mas = [].concat(...mas);
  for (let i = 0; i < mas.length; i++){
    mas[i] = String.fromCharCode(mas[i] + 65);
  }
  return mas;
}
console.log(translateInWord([[6,8,13],[5,3,0]]));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!