Welcome to the Treehouse Community
Looking to learn something new?
Em Ruzzy2,165 Points
My solution worked without escape characters, are they mandatory?
My solution worked without the escape characters in alert().
Do we need to add the escape characters in this problem? I'm not sure why mine worked without them:
var firstName = prompt('Please type your first name.'); var lastName = prompt('Please type your last name.'); var fullName = firstName.toUpperCase() + ' ' + lastName.toUpperCase(); var characterCount = fullName.length; alert("This string " + fullName + " is " + characterCount + " characters long.");
Your code does work without the escape characters, but it will not put quotes around the name. For example, if I enter my name, your output is: this string MIKE FRANCOIS is 12 characters long. With the escape characters added the output would be: this string "MIKE FRANCOIS" is 12 characters long. The escape characters will treat the quotes as a character. hope that helps.
Tyler B5,775 Points
The Solution shown has the full name variable surrounded by quotes. Your version does not have those so you didn't need to escape any of the other characters. To answer your question escape characters will always be mandatory In the case where you are using characters that are reserved for special uses i.e.