JavaScript code error #21397
-
var x = 1; } I am getting an error when i run the code ? I think the answer is 1. Can someone please help ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @aditikochhar and welcome to the community! There are several things going on here that is will cause errors:
This should fix the errors mostly, however I also do recommend to pass the variable that needs the addition as a function argument as well as giving the variable of the product a different name (for clarity). Your code will look something like this then:
Again, these last changes are optional but do improve the quality of the code (at least in my opinion). Please let us know if you have any more questions. PS: next time, please choose a title that fits the topic and put your code in a code block. |
Beta Was this translation helpful? Give feedback.
Hi @aditikochhar and welcome to the community!
There are several things going on here that is will cause errors:
This should fix the errors mostly, however I also do recommend to pass the variable that needs the addition as a function argument as well as giving the variable of the product a different name (for clarity). Your code will look something like this then: