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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![nb11](https://secure.gravatar.com/avatar/dab182685ebcc4b21859f936bfd0c7c1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nb11
17,552 PointsClarity on single and double quotation marks in Node.js?
HI,
I would just like to find out why sometimes in the videos a single quotation is used and sometimes a double, like in the code written below:
var Profile = require("./profile.js");
//Handle HTTP route GET / and POST / i.e Home
function home(request, response) {
//if url === "/" && GET
if(request.url === "/") {
//show search
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write("Header\n");
response.write("Search\n");
response.end('Footer\n');
//if url == "/" && POST
//redirect to /:username
}
}
Like the 4 response lines towards the bottom, the first type one has single ' ', then the next 2 have a double " " and the last a single ' '. Is there a specific reason for this or do they need to be like this for the code to work correctly?
3 Answers
![Iain Simmons](https://secure.gravatar.com/avatar/89ea1833e0ffaf51eb0ef0cf15fa3203?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Iain Simmons
Treehouse Moderator 32,305 PointsThe short answer is that it doesn't really matter, as long as you escape quotes within a quoted string using the same type (escape single quotes in a single quoted string, etc).
Note that JSON requires double quoted strings for everything though.
![nb11](https://secure.gravatar.com/avatar/dab182685ebcc4b21859f936bfd0c7c1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
nb11
17,552 PointsChyno Deluxe, thank you for the link on how to include code correctly, didn't know how to do that!
Iain, thank you for the clarity, appreciate the help.
![Dan Lauby](https://uploads.teamtreehouse.com/production/profile-photos/6869342/micro_dan.jpg)
Dan Lauby
7,897 PointsAlso, in the beginning of the video Andrew copy and pasted example code for creating the server from the Node docs site (single quotes). Then he altered the example code and he used double quotes.
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 Points//Fixed Code Presentation
How to post code