How to fix the error?
Hello,
i think to compare 2 strings you would need to use ===. read more here:
JavaScript String Comparison – How to Compare Strings in JS (freecodecamp.org)
Perhaps, you need 2 changes as shown in the above image.
${item}
should be changed toitem
; no${
and}
should be there.
The symbol
item
here represents a variable name, which is a place to store a string value. On the other hand,${item}
should mean a reference to the value of a variable nameditem
. These 2 are semantically quite different. I think it should be illegal to write a reference${item}
in the 3rd column “Value”.${item}
in the 3rd column should be checked out as an error.
However KR did not complain about${item}
there? Very strange behavior. This indicates that KR considered the${item}
to be a valid variable name. Very confusing. KR shouldn’t behave as this. I think that this is a bug of KR.
→ @vu.tran
"${item}"
should be changed to${item}
; no"
and"
should be there.
The symbol
${item}
stands for a complete string. The symbol"${item}"
stands for a string enclosed by a couple of double quote characters. These 2 strings are different. The latter string is 2 bytes longer than the former.
I am not very sure here. Try leaving
"${item}"
as is and see.
I guess, this message is somewhat malformatted. There must be a bug.
I guess, internally it got
""AE/LLM- ...."" == "AE/LLM- ....."
This looks syntactically odd to me.
So KR says “[error] SyntaxError: Invalid or unexpected token”
Yes, it is a syntactically very odd.
Though the message confuses us.
Hi,
Thanks @kazurayam to suggest a great point that we should remove " "
outside ${item}
.
To my point of view, according to this reference: How to add If else command in recorder - #12 by zoe.lee, ${item}
is right. There should be ${ }
when item
is a variable.
${item}=="abcde"
should work.
Don’t forget to put endIf
to end the if
statement.
Thank you!