• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Problem comparing variables in java script

Community Beginner ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

Hi all!

 

I'm making a word guessing game in captivate and using javascript executed from an advanced action to handle some of the logic.

 

I am trying to compare a guessed letter with the correct letter, but my comparison is not working when the variables should match.

 

To track down the problem, in the below I have set the variables to the same letter. This results in varDebug1 = "grey" where I was expecting it to be "green":

jsLetter1="C";
jsGuess1="C";

window.cpAPIInterface.setVariableValue("varDebug1", "grey");

if ("jsGuess1" == "jsLetter1") {
window.cpAPIInterface.setVariableValue("varDebug1", "green");
}

 

 

I have used typeof to confirm that both variables have the same type, if that might matter. Is there anything I'm doing wrong here?

TOPICS
Advanced , Advanced actions

Views

52

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Feb 20, 2022 Feb 20, 2022

Of course, after looking at this for hours, withion minutes of giving up and asking for help I figure it out. Leaving it here in case anyone else needs to learn from my 'expertise'.

 

I was putting the variable names in quotes, so it was comparing the variable names instead of the variable contents.

Likes

Translate

Translate
Community Beginner ,
Feb 20, 2022 Feb 20, 2022

Copy link to clipboard

Copied

LATEST

Of course, after looking at this for hours, withion minutes of giving up and asking for help I figure it out. Leaving it here in case anyone else needs to learn from my 'expertise'.

 

I was putting the variable names in quotes, so it was comparing the variable names instead of the variable contents.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines