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

135
Vistas
Logger.log(cell.indexOf() always showing -1

I am using a function that fetches values from a range, for this example ["red", "blue", "green"]

function readDataFromRange() {
  var sheet = SpreadsheetApp.getActive();
  var range = sheet.getRange("A:A");
  var cell = range.getValues();
  
  Logger.log(cell[2]);
  Logger.log(cell.length);
  Logger.log(cell.indexOf("green"));

}

this is the result

Execution log

3:23:17 AM  Notice  Execution started
3:23:17 AM  Info    [green]
3:23:17 AM  Info    1000.0
3:23:17 AM  Info    -1.0
3:23:17 AM  Notice  Execution completed

although at index 2 it shows green if ask the index of green it shows -1 and same goes for red and blue any idea why this is happening ?

about 4 years ago · Juan Pablo Isaza
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