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 trialM F
1,985 PointsWhy is var ten not equal to 10?
I am not sure why this code isn't going through... Any thoughts?
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript Foundations: Operators</title>
<link rel="stylesheet" href="core.css">
<script>
var a = 1,
b = 2,
c = 4,
three = c-a,
ten = c*b + b;
/*
Common operators used in numeric calculations:
addition: +
subtraction: -
multiplication: *
division: /
modulus: %
grouping: ()
Your tasks in this code challenge will consist of
creating variables and assigning correct values to
them using only variables a, b, and c and the above
operators. For example, if the task is "Create a
variable named "seven" and assign the correct
numeric value 7 to it using only variables a, b,
and c and the common numeric operators." then one
possible solution would be:
var seven = a + b + c;
Another solution could be:
var seven = (b * c) - a;
Or:
var seven = a + a + a + a + a + a + a;
But that's kinda lame. Good luck! */
</script>
</head>
<body>
<h1>JavaScript Foundations</h1>
<h2>Operators</h2>
<script src="viewer.js"></script>
</body>
</html>
2 Answers
Michael Mayer
6,161 PointsYour code is correct for var ten to be equal to 10, the problem seems to be with how treehouse evaluates your answer. Try assigning 'three' and 'ten' individually:
var a = 1,
b = 2,
c = 4;
var three = c-a;
var ten = c*b + b;
The above worked for me.
M F
1,985 PointsThanks, Michael, this worked!
mtch
8,521 Pointsmtch
8,521 PointsYou have to call it in order to see the result.
Try console.log(ten) or alert(ten).