Global Scope II-Need some help


#1

Need some help! Do not know what to do!

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


#2

what part do you need help with?


#3

The first part. what do they mean by “inside the function, on the very first line of the function”?


#4

//it means within the curly braces of the function.
//The function would be defined as

const name = () => {
//this is the first line;
//this is the second line, etc.;
}


#5

Thanks Sanjay but I did it this way but it is not working, could you explain why?

const satellite = 'The Moon’
const galaxy = 'The Milky Way’
let stars = 'North Star’
stars = ‘Sirius’;
const myNightSky = () => {stars= ‘Sirius’; return ‘Night Sky:’ satellite + ‘,’ + stars + ‘,’ + galaxy};
console.log(myNightSky());
console.log(stars());


#6

you need semicolons after ‘The Moon’ ,‘The Milky Way’, and ‘North Star’. Also on the last line, stars doesn’t have parameters (because it’s a variable), so it doesn’t need the extra parentheses inside the console.log.
console.log(stars);


#7

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