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 The Solution

please help with my code. its not working.

Im not sure why my below code is not working. what did i do wrong?

const question1 = prompt("What is your first name?"); const question2 = prompt("What is your last name?");

let answer = question1.toUpperCase() -'' + question2.toUpperCase(); let number = answer.length(); alert(The string ${answer} is ${number} of characters long);

2 Answers

Hi, Melissa — from the provided code, it looks like you've got just a few minor issues here...

1) In this line of code, it appears like you've made a small syntax error. If you're using concatenation to build up this particular string, you would need to change that - symbol out for a + symbol and add a space between the quotation marks. Here's what it would look like updated:

let answer = question1.toUpperCase() + " " + question2.toUpperCase(); 

2) Secondly, length is actually a property not a function, so it shouldn't have () following it:

let number = answer.length; 

3) Also, it looks like you're missing some backtick marks in that last alert(); dialog. It should have backticks inside the () since it's a string and you're using a template literal. Here's this line of code updated:

alert(`The string ${answer} is ${number} characters long.`);

Try making those changes, and then see if your code will run! :) Also, be sure to check your browser's console to see what's going on if you're experiencing any errors / things aren't working the way they should.

P.S. When posting code in forum, check out the Markdown Cheatsheet located right below the text area where you type your post/comment/answer. It can make it easier for others to easily review your code (and also help when you're answering questions for others)! ;)

I made a couple of errors in my response (Oops; sorry! Going too quickly ha). These have now been updated. ^^

I feel I should have saw those mistakes but Thanks so much!

Back tics? There was no mention of backticks in the tutorial...