Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getting-started-guide.md #2730

Closed
wants to merge 1 commit into from
Closed

Update getting-started-guide.md #2730

wants to merge 1 commit into from

Conversation

nellai-rider
Copy link

The output of console.log was like http://${host}:${port}/, without the variables being printed.

The output of console.log was like http://${host}:${port}/, without the variables being printed.
@@ -21,7 +21,7 @@ const server = http.createServer((req, res) => {
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
console.log(`Server running at http://%s:%d/', hostname, port);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a syntax error. This has changed one of the backquotes to a single quote. In other words, this breaks the template string.

@Trott
Copy link
Member

Trott commented Oct 27, 2019

The output of console.log was like http://${host}:${port}/, without the variables being printed.

The current code is correct. The results you describe are what will happen if you replace the backquotes with single quotes. That will change the template literal into a string. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals for information on template literals.

I'd also be reluctant to make this change because format strings like this are not as idiomatic in JavaScript.

Thanks for the pull request. I'm going to close this. However, that's not to say that the text and code can't stand to be improved and additional submissions would be welcome.

@Trott Trott closed this Oct 27, 2019
@nellai-rider
Copy link
Author

Got it, As I did not copy paste, but typed myself the sample program to get started and got into that problem. I had used single quote and the sample code had back quote enclosure for the string.

The existing code works well with back-quote. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants