Why does it say that I need to use a semicolon before my statement?


#1

I was creating my own RPG when I created this set statement:

if(userAnswer=“Bulbasaur”){
alert (“You chose Bulbasaur!”)
set Pokemon to “Bulbasaur”
set Rivals_Pokemon to “Charmander”}

It keeps saying that I have to put a semicolon before my set statement or else I won’t be able to run it. But, no matter where I put the semicolon (even at the end) it kept saying this error message. Can someone tell me where to place the semicolon?


#2

Programs can rarely tell you what you meant.
It, whatever it is, is likely saying that there is no way to interpret what it is reading, and that the only remaining valid thing where it is currently reading, is a semi-colon.
That does not at all mean you should put a semi-colon there.
Also, the last two lines aren’t valid js


#3

okay, what should the last two lines be?


#4

Like a program, I can’t tell you what you mean.

Programming is to write instructions in a formal language
Formal language here means that only what has been defined in the language can be used, anything else is either undefined behaviour or impossible to process as it has no meaning defined in the language.

So what you’d do is refer to what you mean to describe, and then break that down into operations defined in that formal language, in this case js

If what you mean to do is to create variables and assign values to them, then, hey, that says a whole lot about which formally defined operations you need, and… you know… google… You don’t need me for that.
https://duckduckgo.com/?q=mdn+variable


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.