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) Working With Numbers Numbers and Strings

Shadrach Thomas
PLUS
Shadrach Thomas
Courses Plus Student 8,915 Points

i need help on this challenge

i don't know what i'm doing wrong here

app.js
var width = '190px';
var numOfDivs = 10;
var totalWidth = "parseFloat'('190px') + 'parseInt'('10');
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>

You're using a quotation mark ( " ) on one end and on the other end you're using an apostrophe ( ' ) could that be the issue?

4 Answers

Steven Parker
Steven Parker
229,744 Points

Here's some hints:

  • never put quotes around a function name or a variable name
  • there aren't any float values in this challenge
  • only the width value is a string and will need conversion
  • be sure to use the variables (by name) instead of repeating their literal values
  • the challenge said the formula multiplies the values (not adds)
Steven Parker
Steven Parker
229,744 Points

Do you understand any of the hints? Use the ones that make sense to you to make changes to your code, and then show what the changed code looks like.

Steven Parker
Steven Parker
229,744 Points

What's your code look like after all the changes?

Shadrach Thomas
PLUS
Shadrach Thomas
Courses Plus Student 8,915 Points

var width = '190px'; var numOfDivs = 10; var totalWidth = 'parseFloat'('190px')') + 'parseInt'('10');

Steven Parker
Steven Parker
229,744 Points

That looks the same, except you added one more quote and one more parenthesis. Did you read the hints I gave?

Shadrach Thomas
PLUS
Shadrach Thomas
Courses Plus Student 8,915 Points

please i'm sorry to bother you var width = '190px'; var numOfDivs = 10; var totalWidth = (parseInt('190px') * (numofDivs);

Steven Parker
Steven Parker
229,744 Points

Close, but you should use the width variable, and spell numOfDivs with a capital "O":

var totalWidth = parseInt(width) * numOfDivs;