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 trialJustin Warren
7,805 PointsNeed help in figuring this out. Confused by the wording of it!
Thanks!
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
markmneimneh
14,132 PointsHello
I am not sure exactly which part of code is confusing. Let take a look at the html first.
<!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>
This basically says that you have a web page (index.html) that uses a javascript functionality that is stored in a javascript file called app.js which happens to be residing in same folder as index.html. Now because you are pulling in this file at the end of the body tag, all the html tage will be loaded before the javascript file is loaded.
no moving on to the javascript file app.js
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUppercase();
here in the javascript file, you have 2 variables, id and lastname. you are using the toUpperCase to upper case each one.
so if I add one more line to your javascript file like this
var id = "23188xtr";
var lastName = "Smith";
var userName = id.toUpperCase() + '#' + lastName.toUpperCase();
console.log("<p> my username " + userName + " has been upper'cased </p>");
document.write("<p> my username " + userName + " has been upper'cased </p>");
this should show my username 23188XTR#SMITH has been upper'cased in you web browser.
By the way, you had couple of typos in you js file.
If this answers you question, please mark the question as answered.
Thanks