Visual Studio Code won't run my JS code: compatibility question | re Number Guesser

Hi All,

I’m trying to do the Number Guesser but have run into an issue with my code in Visual Studio Code, where it throws out an error that does not occur in the Codecademy environment. As this is my first attempt at coding in JS outside of Codecademy environment AND the code works otherwise, I think it has to be a compatibility issue.

I’ve tried EVERYTHING, installed all recommended extensions, my Node,js is up to date and the error still occurs. At this point, I’d really appreciate any help you could give me.

I have included the code and the error message below:

const generateTarget = (secret) => {
secret = Math.floor(Math.random() * 9);
return secret


//Codecademy environment generates a random number here, as it is intended to do. But in VSC, I get:

Code Runner error:


ReferenceError: generateTarget is not defined
at Object. (c:\Users\karol\Dropbox\119. Resources\01. Learning and research\Codecademy\Projects\Number_Guesser\number-guesser-starting\tempCodeRunnerFile.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module._extensions…js (node:internal/modules/cjs/loader:1272:10)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
at node:internal/main/run_main_module:23:47

Node.js v19.3.0

[Done] exited with code=1 in 0.066 seconds

Terminal error (for the same code)

Projects\Number_Guesser> console.log(generateTarget());
At line:1 char:28

  • console.log(generateTarget());
  •                        ~

An expression was expected after ‘(’.
+ CategoryInfo : ParserError: (:slight_smile: , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression

Please help O.O