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 trialMuhammad Haris Khan
8,587 PointsCreate a variable named "mevol" and assign the value 16 to it using an octal number literal. NOT WORKING
this is what i did
var mevol = 018;
why is it not working?
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Foundations: Creating Numbers</title>
<link rel="stylesheet" href="core.css">
<script>
// exponential notation
// 1E6 === 1000000
// 1.23E6 === 1230000
// octal number literals
// 06 === 6
// 07 === 7
// 010 === 8
// 011 === 9
// 012 === 10
var GermanyGDP = 3.4E12;
var mevol = 018;
</script>
</head>
<body>
<h1>JavaScript Foundations</h1>
<h2>Creating Numbers: Part 2</h2>
<script src="viewer.js"></script>
</body>
</html>
1 Answer
Stone Preston
42,016 Pointsthe octal value of 16 is 20, not 18.
<!DOCTYPE html>
<html lang="en">
<head>
<title> JavaScript Foundations: Creating Numbers</title>
<link rel="stylesheet" href="core.css">
<script>
// exponential notation
// 1E6 === 1000000
// 1.23E6 === 1230000
// octal number literals
// 06 === 6
// 07 === 7
// 010 === 8
// 011 === 9
// 012 === 10
var GermanyGDP = 3.4E12;
var mevol = 020;
</script>
</head>
<body>
<h1>JavaScript Foundations</h1>
<h2>Creating Numbers: Part 2</h2>
<script src="viewer.js"></script>
</body>
</html>
Muhammad Haris Khan
8,587 PointsMuhammad Haris Khan
8,587 Pointsso after 017 it jumps to 020 to make it 16?
Stone Preston
42,016 PointsStone Preston
42,016 Pointsyes. see this article on how you can convert from decimal to octal by hand. you might also want to read about the octal system and how it works