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

Please give me feedback on code

My code is :

// 2. In this JavaScript file, add a prompt dialog to capture input from the user and store it in a variable var inputUser1 = prompt("Type in your first name");

// 3. Add a second a prompt dialog to capture input from the user and store it in a second variable var inputUser2 = prompt("Type in 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 totalInput = inputUser1.toUpperCase() + ' ' + inputUser2.toUpperCase(); console.log(totalInput);

// 5. Create a fourth variable to store a number. The number should be the total number of characters in the third variable.

var inputUser3 = totalInput.length; console.log(inputUser3);

// 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 " + totalInput + " is " + inputUser3 + ' ' + "number of characters long");

I tried to make the code as simple and following the methods we learnt so far in the JavaScript course.

An improvement I was thinking after finishing the code challenge, was instead of using totalInput to use inputUser1 += .... method

Please give me your feedback!

Regards John

Steven Parker
Steven Parker
243,658 Points

Use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:
Or watch this video on code formatting.

1 Answer

your code seems pretty solid (though it's a little hard to read in the format it's in ). i Can't be sure but there's no space after " 'is' " in your string ( but that could just be because of the format it's in ). i'm only slightly ahead of you in the Javascript course learning arrays. but for what your string is , it'll run just fine. they keep drilling in to us that's there no one real way of writing Javascript. and i can't spot any errors or reason's to give you a syntax error. Good job bro.