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

350
Vistas
How can I make these strings into decimals using map (GAS)?

I'm trying to make sure that the resulting column will onlu contain numbers, but it keeps coming as string.

function moveColsWesbanco() {
  var ss = SpreadsheetApp.getActive();
  var sourceSheet = ss.getSheetByName('Sheet1');
  var destSheet = ss.getSheetByName('New Entry');
  var debitsCredits = sourceSheet.getRange('A7:D');
  var values = debitsCredits.getValues();
  let amounts2 = values.filter(o => o[0] != '').map(e => e[2] != '' ? e[3] = Number.parseFloat(e[2]) : Number.parseFloat(e[3]));
  let allTypes = [];
  for (val in amounts2) {
    allTypes.push(typeof val)
  };
  Logger.log('Types within it: ' + allTypes)
  return;
}

Here are the logs: enter image description here

So...I wonder what I'm missing here. Thank you!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think that when "for in" is used like for (val in amounts2) {}, val is the index. And, it's the string type. I think that this is the reason of your issue. In this case, how about using "for of" as follows?

Modified script:

for (var val of amounts2) {
  allTypes.push(typeof val)
};

References:

  • for...in
  • for...of
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