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

"Cannot read property '1' of null" What am I doing incorrectly?

I've refreshed, restarted my computer, redone this several times. What am I missing? Thanks! :)

app.js
let firstName = "Kim";
let lastName = "DiPasqua";
let role = 'developer';
let msg = `${firstName} ${lastName}: ${role}`;
let roleUpper = role.toUpperCase();
let msg = `${firstName} ${lastName}: ${roleUpper}`;

2 Answers

Hold on, I got it. I needed to change the variable name of line 6. I changed it to newMsg.

I hope this helps someone else, at least! :)

Mark Casavantes
Mark Casavantes
2,880 Points

Hello Kimberly,

Getting a property '1' of null occurs when there is a problem with a variable.

Also, removing the "let" on line 6 would work. Once a variable is initialized, you do not have to initialize it again.

Your solution of changing the variable name works.

On lines 5 and 6, you could write:

role = role.toUpperCase();
msg = `${firstName} ${lastName}: ${role}`;

I hope this is helpful.