Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript The Solution

Feedback on my take on the practice


Looking for feedback on my take on the practice video of variables, input & output in javascript!

var firstName = prompt ("What is your first name?");
var lastName = prompt (" What is your second name?");
var fullName = firstName.toUpperCase()+ ' ' + lastName.toUpperCase();
var numOutput = alert("Your name " + fullName + " is " + fullName.length + " characters long.");

3 Answers

Jamie Reardon
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Looks great and does what is intended! Only thing I could think of that maybe you could add to further improve the purpose and description of the variables is the last one numOutput has one purpose on this script like the others. The other three variables have clear meanings for this script, I would personally rename the variable to something like nameLength or stringLength. It just gives it that more clarity when reading and understanding the purpose the variable since numOutput could also consider to be calculating numbers for example.

Thank you! =D yes I was struggling with a name for that one.

Question: Won't this solution calculate the number of characters including the space?