# \[error\] SyntaxError: Invalid or unexpected token

**URL:** <https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122>\
**Category:** Web Testing\
**Tags:** katalon-recorder\
**Created:** [December 1, 2022, 2:23am UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122 "2022-12-01T02:23:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![haolye1999](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/haolye1999/32/20483_2.png) [@haolye1999](https://forum.katalon.com/u/haolye1999)\
**Post date:** [December 1, 2022, 2:23am UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/1 "2022-12-01T02:23:55Z")

</div>

How to fix the error?

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/0/5/0598da246539c7532142306a07484cc61050a181.png)  
 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/c/5/c5e1702d22838a217793ad96f013e8e376f822ad.png)

---

<div class="post-metadata">

**Author:** ![Andrej\_Podhajsky](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/andrej_podhajsky/32/1055_2.png) [@Andrej\_Podhajsky](https://forum.katalon.com/u/Andrej_Podhajsky)\
**Post date:** [December 2, 2022, 12:50pm UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/2 "2022-12-02T12:50:28Z")

</div>

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)](https://www.freecodecamp.org/news/javascript-string-comparison-how-to-compare-strings-in-js/)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 2, 2022, 1:07pm UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/3 "2022-12-02T13:07:49Z")

</div>

![スクリーンショット 2022-12-02 22.01.07](https://europe1.discourse-cdn.com/katalon/original/3X/c/d/cd8b7a6604080e24ac0cdaba87850883f3eeeb21.png)

Perhaps, you need 2 changes as shown in the above image.

1. `${item}` should be changed to `item`; 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 named `item`. 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

1. `"${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.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [December 2, 2022, 1:26pm UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/4 "2022-12-02T13:26:25Z")

</div>

![スクリーンショット 2022-12-02 22.22.55](https://europe1.discourse-cdn.com/katalon/optimized/3X/0/9/09fb38c27359aa9d655542ffee80684a09a399a9_2_690x21.png)

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.

---

<div class="post-metadata">

**Author:** ![vu.tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/vu.tran/32/20584_2.png) [@vu.tran](https://forum.katalon.com/u/vu.tran)\
**Post date:** [December 6, 2022, 1:37am UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/5 "2022-12-06T01:37:54Z")

</div>

Thank @kazurayam, let me raise to our product team.

---

<div class="post-metadata">

**Author:** ![Elly\_Tran](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/elly_tran/32/21874_2.png) [@Elly\_Tran](https://forum.katalon.com/u/Elly_Tran)\
**Post date:** [December 6, 2022, 3:51am UTC](https://forum.katalon.com/t/error-syntaxerror-invalid-or-unexpected-token/81122/6 "2022-12-06T03:51:21Z")

</div>

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](http://forum.katalon.com/t/how-to-add-if-else-command-in-recorder/13620/12), `${item}` is right. There should be `${ }` when `item` is a variable.

```auto
${item}=="abcde"

```

should work.

Don’t forget to put `endIf` to end the `if` statement.

Thank you!
