In client script, how can we write if else statements with syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2021 12:22 AM
when I am trying to declare else, then it's showing an error unexpeced token else. How could I resolve it.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2021 12:25 AM
Hi,
Its same way you use everywhere else
if(condition){
}else if(condition)
{
}else if(condition)
Please share your current code to understand where is the error
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2021 12:31 AM
Can you show script?
There is nothing out of the ordinary here but simple Javascript syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2021 12:41 AM
Post your code here so that we can see what has gone wrong. I think you might have added extra semi colon before else.
Syntax:
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2021 08:23 AM
Thank you very much for helping me in clarifying the query.