JavaScript: Scope

Lesson:
https://www.codecademy.com/courses/learn-javascript-scope/lessons/scope/exercises/global-scope?action=lesson_resume&course_redirect=introduction-to-javascript

These are the errors that I get:
Does the code contain a function named myNightSky() defined with const?
Did you write a console.log() statement beneath the close of the function block?
Did you pass the myNightSky() function to console.log() as an argument?```

It may be due to the short hand nature of the arrow function, or possibly the string interpolation. Either way is this a bug or am I missing something?


const satellite = 'The Moon';
const galaxy = 'The Milky Way';

let stars = 'North Star';

const myNightSky = () => `Night Sky: ${satellite}, ${stars}, ${galaxy}`

console.log(myNightSky());


The instructions ask us to use concatenation, not string interpolation (back tick syntax).

return 'Night Sky: ’ + satellite + ', ’ + stars + ', ’ + galaxy;

1 Like

While the example does show concatenation, it does not explicitly say you must/should use it. It says ā€œstatement like thisā€ the example shown.

If it works, and is not generally considered bad form, then the answer should be accepted. It is confusing for students otherwise.

I’ve run into this with other examples that want you to define a constant variable like:

const name = "Alex";

and gives you an error when you do:

const name = 'Alex';

I am still learning, so please correct me if I am wrong, but these are exactly the same way of defining a string constant right?

1 Like

It is quite common for the lesson checking program (SCT) to not be exhaustive so we should assume that not all submissions will be accepted, even though they are programmatically sound.

When you encounter situaltions like this, then the course of action would be to submit a Bug Report with your suggestions. Posting it in the track Q&A is not the best place to post your comments. It’s just so much white noise on the forums.

1 Like

That is understandable, although I’d expect the lessons to be a bit more explicit if the lesson checking program is unable to determine if the code meets the criteria.

I posted this here because I am a student, and I was not certain if there was something I was missing. There are plenty of times I am sure I did something correct, only to realize I made a simple mistake. I’d be more concerned with a bunch of bug reports containing user errors, but if that is how you want it to be done, I have no problem doing that.

Anyways, appreciate the assistance.

Actually, there are a couple of forums that one would hope the folks on the corporate side are keeping up with:

Platform Problems

Suggestions

Please don’t take me too seriously concerning the ā€˜white noise’ comment. It’s not something we can do anything about and get comments on a daily basis that just make our eyes roll, being hamstrung on the volunteer side of things.

1 Like

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