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 trialRichard Reis
Courses Plus Student 8,907 PointsIs this a bug?
I tried to do the second task therefore I wrote:
var mevol = 018;
But it keeps giving me an error.
This is a very simple task so either I'm making a huge mistake without realizing it or there's a bug.
3 Answers
Holger Liesegang
50,595 PointsHi Ricardo,
Challenge task 2 of 2 of "Create a variable named "mevol" and assign the value 16 to it using an octal number literal." asks you to assign an octal literal of 16 to the variable and that would be 020:
var mevol = 020;
Richard Reis
Courses Plus Student 8,907 PointsThank you everyone for your help I completely understand it now
Richard Reis
Courses Plus Student 8,907 PointsAnd I agree with Dino Paškvan
Andrew McCormick
17,730 PointsAndrew McCormick
17,730 PointsQuick explanation of why
020
is correct. In octal the first number is the number of eights and the second is the number of ones. Examples: Octal = base 10 equivalent03 = 3 //zero eights and 3 ones
10 = 8 // 1 eight and zero ones
017 = 15 // one eight plus 7 ones
020 = 16 // two eights and zero ones
remember that in Octal you only have the numbers 0,1,2,3,4,5,6,7 to use.
Dino Paškvan
Courses Plus Student 44,108 PointsDino Paškvan
Courses Plus Student 44,108 PointsIt might be time to remove this part of the deep dive. Octal literals have been deprecated since ES3 (in strict mode). They're only still allowed for backwards compatibility.
ES6 will have a different octal/binary literal syntax which will make more sense and appear less confusing.