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

132
Views
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
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!