JavaScript JavaScript Basics Working with Strings Combine and Manipulate Strings

Felix Nicol
Felix Nicol
856 Points

What is wrong with this syntax? It is not accepting it and coming up with errors.

app.js
let firstName = 'Felix';
let lastName = 'Nicol';
let role = 'developer';


let msg = firstName + ' ' + lastName + ':' + role + '.';
let newMsg = role.toUpperCase();

1 Answer

You almost correct, the question says just convert role variable to with toUpperCase() method., and didn't mention about a new variable like 'let newMsg'

let firstName = 'Felix';
let lastName = 'Nicol';
let role = 'developer';


let msg = firstName + ' ' + lastName + ': ' +  role.toUpperCase();  
Felix Nicol
Felix Nicol
856 Points

Man thanks so much. I could not figure out what I was doing wrong. Lifesaver! cheers

You can do like this

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

Its call ' Template literals '