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 trial

JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables Review Strings, Numbers and Spaces

he;p

a

Billy Bellchambers
Billy Bellchambers
21,689 Points

What exactly seems to be the problem we will need some detail in order to assist you?

Matthew Smart
Matthew Smart
12,567 Points

Oh dear, please re-think your question and update it.

How is it possible for us to help you when we have no idea what the problem is your experiencing?

Steven Parker
Steven Parker
229,744 Points

There's a link to a quiz, but the quiz has 5 questions. Which one has you stumped?

1 Answer

Matthew Smart
Matthew Smart
12,567 Points

Due to the fact you haven't refined your question, I will produce the answers for you here. But explain why they are correct for any future students.

Q1 - What of the following is an example of a string? A - The correct answer for this is "Hello world!"

A string has got to have the same quote marks around it. For example "test" and 'test' are correct, but "test' is incorrect. The answer would not be text without any quote marks as Javascript needs to find quotes around text to make it a string. The answer would not be 10 because that is an integer. However if it was '10' or "10" then that would become a string as opposed to an integer.

Q2 - In many cases, JavaScript ignores space such as tabs, new lines and the space character. But not always. Which example below will cause a JavaScript error? A - The correct answer would be var days In Week = 7;

The reason for this is that a variable cannot have any spaces in the name. Before or after the variable you could have 1 million spaces/tabs and javascript would understand they are the same equation.

Q3 - Which of the following creates the variable message and stores a string value in it? A - This would be var message = "These are not the droids you're looking for";

If you look at the string, the message contains the word - (you're). Now if we had a string like - ' you're '; Javascript would think that the end of the string is at the character u, which would then cause a syntax error.

Q4 - Add spaces to your programs if it makes your code easier to read and understand. A4 - Although that seems more like an instruction than a question, Andrew Chalkley :) the answer is true

The reason is because javascript will not consider how much space/indents/line breaks you make, as long as your syntax is correct it will work the same however its laid out. This is perfect for us as developers to indent our code and make it as readable as possible not only for ourselves but for future developers that may dive into out code at a later date. If you code is all together and not separated and using comments, it can be incredibly hard to remember what logic you was making 6 months ago.

Q5 - Please fill in the correct answer in each blank provided below A - the answer is \

This will escape a quote in a string. For example

var text = 'Hello you\'re eating some of your pizza!';

This will read as - Hello you're eating some of your pizza! Where are:

var text = 'Hello you're eating some of your pizza!';

Will create a syntax error.