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 JavaScript Basics Working with Strings Combine and Manipulate Strings

Assign your first name to variable firstName and your last name to variable lastName

I don't know how to do it

Let firstName = prompt("What is your fisrt name?");
Const lastName = prompt("What is your Last name?");
firstName += lastName;

3 Answers

Steven Parker
Steven Parker
220,925 Points

You won't need to use prompt in this challenge. Just encode your names as literal strings.

You also won't modify the initial values after assignment. In a later step, you will create a new variable to combine them.

Rick Gleitz
Rick Gleitz
45,802 Points

Also, let and const begin with lower case letters. No need to mix them. They can both be let.


Sara Pena
Sara Pena
5,459 Points

Assign your name to the variables just means to add your name to each variable as 'strings'.

Also, if you intend to eventually change or update the values of your variables, choose 'let'. Otherwise, keep 'const'.

As you might have learned earlier in the course, 'var' is no longer used due to scoping reasons. Meaning, it can be seen inside or outside code blocks and could potentially harm your code by changing values of your 'var' unintentionally.

Let example:
let x = 1;
let z = 2;
x + z = 3;
x = 2;
x+ z = 5;

Const example: const x = 2; const z = 5; x = 10; // this will return as undefined x + z = 7;

Assign a number to variable x,

x =