Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Alexander Foster
Alexander Foster
4,725 Points

Using exponential notation, create a variable named "GermanyGDP" and assign the number 3.4 trillion (3400000000000) to it.

Anyone else typing the right answer in and having the code editor tell you to use "Exponential notation?" I typed in var GermanyGDP = 3.4E12 which is 3400000000000 like it is asking for but it is saying i am not using exponential notation...which clearly i am.... I also tried 34E11 whih is also 34 trillion but that doesnt work either... Is it a bug or am i missing something? It works in my my javascript console..sooo ooo

7 Answers

Numbers that begin with 0x are actually hexadecimal numbers (base 16). Using hexadecimal, 0x10 is equal to 16, but that's because hexadecimal numbers are base 16. Octal numbers are base 8.

In decimal notation (our regular everyday base 10 number system), the rightmost digit is the"ones" digit, the digit to the left of that is the "tens" digit, the digit to the left of that is the "hundreds" digit and so on. Notice that each digit ("ones", "tens", "hundreds", "thousands", and so on) is ten times more than the digit to its right (which is why it's a base 10 number system).

So following the same pattern with octal (base 8) notation, each digit place is eight times more than the digit place to its right because the number system is base 8. Hopefully this example makes it a little more clear.

In a decimal (everyday base 10 system), the number 1234 can be looked at like this:

1234 = (1 * 1000) + (2 * 100) + (3 * 10) + (4 * 1)

Taking the number 1234 into octal (base 8) it would be

01234 = (1 * 512) + (2 * 64) + (3 * 8) + (4 * 1) = 668 in decimal

The reason the question is saying to add 2 to the octal number 016 is because 016 equals 14 in decimal ((1 * 8) + (6 * 1)). So you need to add 2 to it to get 16 decimal. However, keep in mind that in octal notation, there is no single digit for the number 8, just as in decimal notation there is no single digit for the number 10.

For instance, in decimal if you add 18 + 2, you get 20. So in octal notation, if you add 016 + 02 you get...

I copied that line of code directly from your post and it worked for the quiz. It looks like you did everything correctly. I don't know why it's not passing. Here's the complete code I'm using, which is passing the quiz.

<!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
    </script>
    </head>
    <body>
    <h1>JavaScript Foundations</h1>
    <h2>Creating Numbers: Part 2</h2>
    <script src="viewer.js"></script>
    </body>
</html>
James Barnett
James Barnett
39,199 Points

Ben Rubin - You forgot your semicolon at the end of your line of JavaScript.

Also remember our goal here on the forum is give help not answers, we are here to encourage and guide those needing help, and not just give them an answer.

Need more explanation on the distinction check this out.

I posted my code to demonstrate that I copied Alexander's code exactly as he posted it and it passed the quiz. I didn't give him anything that he didn't already do.

James Barnett
James Barnett
39,199 Points

You forgot your semicolon at the end of your line of JavaScript.

Juliano Vargas
PLUS
Juliano Vargas
Courses Plus Student 15,575 Points

please anyone can help me with this question : Create a variable named "mevol" and assign the value 16 to it using an octal number literal. this i what i tried 010 it says to add 2 to your octal literal 016. i am not sure where to add it I know this 0x10 will give me 16 but will give for the task anyone ?

Juliano Vargas
PLUS
Juliano Vargas
Courses Plus Student 15,575 Points

humm so the answer will be 020 i get it thank's for that

Alexander Foster
Alexander Foster
4,725 Points

Thanks for the help guys, My problem was that i didnt put the script in the right tag.....Haha just a case of not paying attention. Love how quick this form is to help those in need! thanks guys

I found this Youtube tutorial useful in understanding octal numbering et al!

https://www.youtube.com/watch?v=5sS7w-CMHkU