You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm stuck on the second exercise. Instructions are:
Create a file named variables.js.
In that file declare a variable named example.
Make the variable example equal to the value 'some string'.
Then use console.log() to print the example variable to the console.
Check to see if your program is correct by running this command:
javascripting verify variables.js
So,
I've created a file called variables.js. I open that file with:
nano variables.js
Then I type this in the file: (this where I think I've missed something or messed up??????)
let example
const example = 'some string'
console.log(example)
Save and exit. Then I verify and I get this error...
SyntaxError: Identifier 'example' has already been declared
at Object.compileFunction (node:vm:355:18)
at wrapSafe (node:internal/modules/cjs/loader:1022:15)
at Module._compile (node:internal/modules/cjs/loader:1056:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
at ChildProcess.exithandler (node:child_process:326:12)
at ChildProcess.emit (node:events:369:20)
at maybeClose (node:internal/child_process:1067:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
@caro-turnbull bro
in your code let example const example = 'some string' console.log(example)
it should be const example = 'some string' console.log(example)
filrst you have declare example variable with let in 1st line then in 2nd line you declaring it with const
use let or const for same variable name
I'm stuck on the second exercise. Instructions are:
Create a file named variables.js.
In that file declare a variable named example.
Make the variable example equal to the value 'some string'.
Then use console.log() to print the example variable to the console.
Check to see if your program is correct by running this command:
javascripting verify variables.js
So,
I've created a file called variables.js. I open that file with:
nano variables.js
Then I type this in the file: (this where I think I've missed something or messed up??????)
let example
const example = 'some string'
console.log(example)
Save and exit. Then I verify and I get this error...
Error: Command failed: node "/Users/carolineturnbull/lighthouse/javascripting/variables.js"
/Users/carolineturnbull/lighthouse/javascripting/variables.js:2
const example = 'some string'
^
SyntaxError: Identifier 'example' has already been declared
at Object.compileFunction (node:vm:355:18)
at wrapSafe (node:internal/modules/cjs/loader:1022:15)
at Module._compile (node:internal/modules/cjs/loader:1056:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
killed: false,
code: 1,
signal: null,
cmd: 'node "/Users/carolineturnbull/lighthouse/javascripting/variables.js"'
}
The text was updated successfully, but these errors were encountered: