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!

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


Create a Variable named "mevol" and assign the value 16 to it using an octal number literal

octal number literals // 06 === 6 // 07 === 7 " " " " 012 === 10 013 === 11 " " " " My code was: var mevol = 018; before used: var mevol = 016; and the error message say's add 2 to the decimal number 016. I added two accord to the chart above but keep's comming up with error code <code> var = 021 </code> what am I doing wrong tried many different ways including 0216 and many more

9 Answers

James, does this help? You can see the pattern here. Rember it's base 8. 07=7 010=8 011=9 012=10 013=11 014=12 015=13 016=14 017=15 020=16 021=17 022=18 023=19 024=20 025=21 026=22 027=23 030=24

How would this work for 4 digits? I understand how it works for 3 but cannot work out how it would work for 4.

Thanks in advance

Thanks Jamie

Kyle Brooks
Kyle Brooks
6,753 Points

Tony, you have to add two for each octal. In this case, it would be adding 4, which should give you var mevol = 020 (If I recall my answer correctly on the code challenge).

Bob Sutherton
Bob Sutherton
20,160 Points

But why is this? I was following the same logic as Tony which says that if 01 = 8 then 018 = 8 + 8 which should give 16. What are we missing? Why do you suddenly add four places instead of two?

018 wouldn't technically exist because Octal only goes until 7. (0 1 2 3 4 5 6 7 and restart.)

Nice thanks very much!!

Think of the "2" (in the answer 020) as representing two "8"s. So 0 + two 8s = 16 + 0 = the answer: 16. Another example: 030. Think of the 3 as representing three 8s or 24. So 030 = 24.

When would you even need to use this?

Apparently, per the video, it's rare in JS. It seems the information was included so that coders will avoid placing a zero before their numbers. Found this on stackoverflow: "Octal is used as a shorthand for representing file permissions on UNIX systems."

Regan O'Neill
Regan O'Neill
12,714 Points

Thank you for your help here! The video did a poor job of explaining how this works. In order to be more helpful and communicate the nature of octal numbers, they should use another example than just numbers with a middle digit of 1 - For example) 012, 015, etc.