I think Part 4 (of 11) in the Comparison Operators is broken.
I can’t get it to process for the first instruction
( Using let
, create a variable named hungerLevel
and set it equal to 7
.)
I have tried on my own and used the solution but it will not accept the code to declare the variable and set it equal to 7. It just keeps defaulting to wrong.
Clicking “Solution” puts all the code in and it accepts all the steps as complete so I can bypass it but it will not accept:
Start of Code
let hungerLevel = 7;
End of Code
as a way of satisfying the first instruction even though it is the exact same code that is produced by the solution.
Same happened to me, i compared my own (wrong?) solution to the given one and its exactly the same. The codeacademy solution doesn’t run in the console either.
Having the same issue:
let hungerLevel = 7;
if (hungerLevel) > 7 {
console.log('Time to eat!')
else {
console.log('We can eat later!')
}
1 Like
I think the correct code is:
let hungerLevel = 7;
if (hungerLevel > 7){
console.log('Time to eat!');
}
else {
console.log('We can eat later!');
}
Hi, I put exact the same code:
let hungerLevel = 7;
if (hungerLevel > 7){console.log(‘Time to eat!’)};
else {console.log(‘We can eat later!’)};
Unfortunately didn’t work. This is what I get:
/home/ccuser/workspace/learn-javascript-conditionals-comparison-operators/main.js:5
else
^^^^
SyntaxError: Unexpected token else
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
Can anyone help? Thanks a lot in advance
extra semi-colons at the wrong places can interrupt your code.
Thanks Stetim, deleted 2 semi-colons & it works.
Code looks like this now:
let hungerLevel = 7
if (hungerLevel > 7)
{console.log(‘Time to eat!’)}
else
{console.log(‘We can eat later!’)};
And works :D. Thanks a lot
Does not seem correct here, check the code I sent before.
Thanks, problem already sorted