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 (Retired) Storing and Tracking Information with Variables Using String Methods

Use the JavaScript .toUpperCase( ) string method to assign an all uppercase version of the id variable to the userName v

need help

app.js
var id = "23188xtr";
var lastName = "Smith";

var userNam.toUpperCase(lastName);
index.html
<!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>

2 Answers

Charles Kenney
Charles Kenney
15,604 Points

Francisco,

You're on the right track but you need to make sure to follow the syntax for assigning a variable and spell consistently with the problem. This challenge instructs us to assign a value to 'userName', not 'userNam'. We need to transform the casing of the Id variable to uppercase and assign it to the 'userName' variable. To do this, we call the string method 'toUpperCase' using dot notation, like so:

var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase();

Then we need to concatenate the new Id with the a hash ("#") and the last name of the user (also to uppercase). Just as before, we can simply write:

var id = "23188xtr";
var lastName = "Smith";

var userName = id.toUpperCase() + '#' + lastName.toUpperCase();

Hope this helps,

Charles

Ezra Siton
Ezra Siton
12,644 Points

You have syntax errors in line 4 (JS). You can not use the dot like this (before you declare the var)

Uncaught SyntaxError: Unexpected token .

Second error syntax. The toUpperCase dont get any parameters. toUpperCase(string) like you wrote - will throw this error:

Uncaught ReferenceError: toUpperCase is not defined

The correct syntax is :

string.toUpperCase()

Fix errors 1 and 2:

var userName = id.toUpperCase();