Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Functions Pass Information Into Functions Variable Scope

Input 'person' - why not at same time as Variable Scope?

The code works, but what I feel I'm missing is why don't we, at the same time, learn to enter the inputs for each name. My code works, and I understand why, but does managing input come later? We did some earlier. I don't want to miss an important step. I'm just curious and appreciate any insights!

Best to all: Andrew Faw

Script code: let person = 'Lee';

function greeting() { // Function scope let person = 'Meg'; alert(Hi, ${person}!); }

function greeting2() { // Function scope let person = 'Robert'; alert(Hi, ${person}!); }

greeting(); alert(Hi, ${person}!); greeting2(); // This returns the 3 different people.