That is not valid JavaScript code in the screenshot, as the JavaScript variable is not declared. I'd advise taking the Learn JavaScript in Construct course which will likely answer many of your initial questions. The Integrating events with script example also demonstrates passing values between event sheets and JS code.
Thanks, I thought the variables we create in Event Sheet are the same JavaScript variables that we can access in scripting. But you say the two are different.
Yes, I searched and I was looking for such a tutorial that you put a link to, but I could not find it on the site. I think categorizing site links is a bit confusing.