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 trialWalter Alexandros Vogiatzis
Courses Plus Student 1,778 PointsBummer! Did you add the '#' character between `id` and `lastName`? Can someone help what am I missing?
Bummer! Did you add the '#' character between id
and lastName
? What am I missing? My code is:
var userName = (''id".toUpperCase() + "#" + "lastName".toUpperCase());
var id = "23188xtr";
var lastName = "Smith";
var userName = ('id'.toUpperCase()+'#'+'lastName'.toUpperCase());
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
1 Answer
Justin Black
24,793 PointsPretty sure your code should read:
var userName = (id.toUpperCase()+'#'+lastName.toUpperCase());
Walter Alexandros Vogiatzis
Courses Plus Student 1,778 PointsWalter Alexandros Vogiatzis
Courses Plus Student 1,778 PointsThank you Justin!
Justin Black
24,793 PointsJustin Black
24,793 PointsNo problem Walter, happy to help. Keep in mind, for future reference that in JavaScript ( and many other languages ) single quotes ( ' or ` ) and double quotes ( " ) function identical.
Anything contained within them is treated as a literal string. So, when you had 'id'.toUpperCase() you created a string object containing the word "id", and were bringing that to be uppercase resulting in "ID". This is valid, but in this particular phase of the JavaScript tutorial, you have defined the variables id and lastName.
So to use these variables, you just type out their reference identifier: console.log(id.toUpperCase()) which would be the same as typing: console.log("23188xtr".toUpperCase()) or console.log('23188xtr'.toUpperCase())