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 ?