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
Victor Gordian
4,656 PointsTrying to get someones name
I'm doing a little project but I think ill be able to connect with the user if I knew their name, I just dont know which clip shows that. If someone can help me on finding it or giving me info on how to gather info from the user, so far i have done
var name = prompt("What is your name?"
i guessed on the next function, sorry.
var greeting = function(name){ (console.log("Hello" + " " + name));
}; greeting("name");
1 Answer
Eric Buchmann
15,080 Pointsvar name = prompt('What is your name?');
console.log('Hello ' + name);
The first line should get the name from the prompt window and put it into the variable name, then you can use that variable however you want. In your example above you're just missing the '); at the end of the prompt code.
Victor Gordian
4,656 PointsVictor Gordian
4,656 Pointsit doesn't pop out anymore, it says syntax error
nevermind i got it, but it comes out in the console..how do i make it come out on the page?
oh i get it now, javascript doesnt have any out put functions!
Eric Buchmann
15,080 PointsEric Buchmann
15,080 Pointsdocument.write('string'); would output something to the document. There are other ways too, but they'll get covered later.
Victor Gordian
4,656 PointsVictor Gordian
4,656 PointsRight, but that's in the html file, not the JavaScript, right?