Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

64
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 ?

7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos