I have equal strings coming up as not equal in a google apps script function and can't figure out why. Other answers to this question on the forum are in other languages I don't understand yet. Here's the code:
function testForMatch() {
var ss = SpreadsheetApp.getActive();
var masterSheet = ss.getSheetByName('Leaderboard');
var masterLength = masterSheet.getMaxRows() - 3;
var masterData = masterSheet.getRange(4, 2, masterLength).getValues(); //gets all the student names from the leaderboard
var titleSheet = ss.getSheetByName('Title - Standard scores');
var titleLength = titleSheet.getMaxRows() -3;
var titleData = titleSheet.getRange(4, 2, titleLength).getValues(); //gets all the student names from the standard score sheet
for ( i = 0; i < masterLength; i ++) {
if(masterData[i] != titleData[i]) {
var row = i + 1;
var error = "Uh oh! It looks like " + masterData[i] + " and " + titleData[i] + " do not match in row " + row;
var ui = SpreadsheetApp.getUi();
var response = ui.alert(error);
}
}
}
even if I just type simple strings into the matching cells it tells me they don't match. Likewise for numbers.
Only thing I can think is that my script isn't actually comparing the values. If that's true, how do I get it to do that?
Thanks for helping!