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 trialErik L
Full Stack JavaScript Techdegree Graduate 19,470 PointsI cant get my last name to pop up
I can't het my last name to pop up in the browser at the end when I try to see the total count of space between the two variables, can anyone help? this is my code:
// 1. Attach this file -- practice.js -- to the index.html file using a <script> tag //Check // 2. In this JavaScript file, add a prompt dialog to capture input from the user and store it in a variable var firstName = prompt("What is your name");
// 3. Add a second a prompt dialog to capture input from the user and store it in a second variable var lastName = prompt("What is your last name"); // 4. Create a third variable and which combines an uppercase version values in the two other variables separated by a space. For example, if the first two variables contain "sally" and "forth", this third variable should contain the string value "SALLY FORTH" var completeName = firstName.toUpperCase(); + ' ' + lastName.toUpperCase(); // 5. Create a fourth variable to store a number. The number should be the total number of characters in the third variable. var characterCount = completeName.length; // 6. Add an alert dialog box that says "The string '[insert value of third variable here]' is X number of characters long." For example, if the third variable contained the string "SALLY FORTH" then the alert dialog should says "The string 'SALLY FORTH' is 11 characters long." alert("The string \"" + completeName + "\" is " + characterCount + " characters long");
1 Answer
Steven Parker
231,248 PointsYou have a stray semicolon keeping the last name from being added:
var completeName = firstName.toUpperCase(); + ' ' + lastName.toUpperCase();
// ^
// remove the stray semicolon
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 PointsI see thanks so much!
Erik L
Full Stack JavaScript Techdegree Graduate 19,470 PointsLike this?
var completeName = firstName.toUpperCase() + ' ' + lastName.toUpperCase();
Steven Parker
231,248 PointsDidn't that fix it? If not, try re-posting the whole code (with formatting).
Steven Parker
231,248 PointsSteven Parker
231,248 PointsWhen posting code, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. Or watch this video on code formatting.