Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda