dimanche 24 février 2019

Very simple if/else statements seem to be working backwards

I have been looking at this simple if/else statement in another larger project and I can't seem to find what I am doing wrong.

I have inserted Logger.log() in both if statements to try to root out the problem.

When I run the code, I get the following Log:

[19-02-24 08:50:05:427 PST] var Campus = Baylor

[19-02-24 08:50:05:428 PST] var TSTCCampus = TSTC

[19-02-24 08:50:05:428 PST] if IS= statement executed

[19-02-24 08:50:05:428 PST] else NOT= executed

The two variables are clearly NOT equal but the if = executes and the else != executes.

What am I doing wrong?

function myFunction() {

// call the Current Reults sheet and identify the Last Row of Responses
  var RawFormResponsesSheet = SpreadsheetApp.getActive().getSheetByName("Current Results");
  var CurrentSubmission = RawFormResponsesSheet.getLastRow(); // Retruns the Value of the Last Submission Row Number
  var Campus = RawFormResponsesSheet.getRange(CurrentSubmission,3).getValue();

// call the Email Data sheet and identify certain cell values
  var EmailDataSheet = SpreadsheetApp.getActive().getSheetByName("Email Data")
  var TSTCCampus = EmailDataSheet.getRange(3, 4).getValue();
  var BaylorCampus = EmailDataSheet.getRange(4, 4).getValue();

Logger.log("var Campus = " + Campus)
Logger.log("var TSTCCampus = " + TSTCCampus)

if (Campus = TSTCCampus){Logger.log ("if IS= statement executed")}
else {Logger.log ("else IS= executed")}

if (Campus != TSTCCampus){Logger.log ("if NOT= statement executed")}
else {Logger.log ("else NOT= executed")}

}

Aucun commentaire:

Enregistrer un commentaire