Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Simple javascript problem using 'if' and '&&'

Not applicable
Could anyone please explain why my IF statement is not executed as being true"tf_Company.rawValue: " + tf_Company.rawValue, "Debugging", 3);"tf_Type.rawValue: " + tf_Type.rawValue, "Debugging", 3);

// At this point tf_Company is Integral and

// tf_Type is Modification

// However, the 'if' statement fails and does not display

// "In the IF Statement"

// The "After" is displayed.

if (tf_Type.rawValue == "Modification" && tf_Company.rawValue == "Integral")

{"In the IF statement", "Debugging", 3);

tf_Company.rawValue = "TBA";

};"After", "Debugging", 3);
0 Replies
Level 4
Level 4
If there is any difference in whitespace, the == operation won't match the strings.

One way you can spot if there is a whitespace difference is by putting some recognisable characters directly before and after the values in your debug box:

>"tf_Company.rawValue: >>" + tf_Company.rawValue + "<<", "Debugging", 3);

Might not be the cause in this case, but worth eliminating as a possibility.

Also, I think == is case sensitive, does the case match with what is shown in the debug box?
Level 5
Level 5
You might try testing each condition within parenthesis:

if ((tf_Type.rawValue == "Modification") && (tf_Company.rawValue == "Integral"))
Not applicable
Thank your for your help.

Yes, there was 1 space before the word "Integral".

I had never noticed. This has led me to look at other fields in the form and they all start 1 space in.

However, in another form that I have developed, there is no 1 space before the text when I enter text into a Text Field.

Would you know the reason for the 1 space before the text and how I eliminate it.