Mistake In a Script

What is the mistake in this script?


Thank you.

Hi @r4356th,

  • First of all, if you want you use some data inside a JS function, you must use its inputs. Something like this:

  • Of course, if you use JS block inside a call, you need to report something (return something;)

  • And I don't understand the main idea of your example... but I guess it's only an example and your JS will do more things. If not, it has no sense.

Joan

I see. Thank you.

Also I'm pretty sure you can't use a question mark in a variable name.

I see.

i JUST CHECKED IT. THANK YOU.

A question mark (with a colon) is used for the ternary operator.

May I ask you what a ternary operator is?

expression1 ? expression2 : expression3

First, expression1 is evaluated. If it is truthy (true boolean or true if converted to boolean), expression2 is evaluated and returned, and expression3 is skipped. Otherwise, expression2 is skipped, and expression3 is evaluated and returned.

The reporter if-else in Snap! does the same thing that the ternary operator does.

Thank you.

It's
Untitled script pic (10)
but in Javascript

Okay.