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

Gavin Winstanley
Gavin Winstanley
190 Points

struggling to understand where I am going wrong with this code? const firstName = "Gavin" const lastName = "Winstanley"

app.js
const firstName = "Gavin"
const lastName = "Winstanley"
const role = 'developer'
var msg = firstname + ' ' + lastname +' ':; + role:;

1 Answer

Hi Gavin!

Task 1 looks good (but I'd stick to consistent quotes - use all single or all double).

Task 2 the syntax is close but needs some fixes, like this (notice the Name part of the vars should be capitalized/camelCase in the msg)

const firstName = 'Gavin';
const lastName = 'Winstanley';
const role = 'developer';
var msg = firstName + ' ' + lastName + ': ' + role;

Make sure your msg spacing is accurate!

For Task3, just add .toUpperCase() to role.

Keep in mind Task 3 could also be written (using template literal syntax) like this:

var msg = `${firstName} ${lastName}: ${role.toUpperCase()}`; // make sure to wrap it in backticks

I hope that helps.

Stay safe and happy coding!