Can a space be at the beginning or end of a string?

Does it matter if a space before the quote(s) is placed before or after a string when you want to get a space between the strings?

Spaces inside the quotes will render with the string.

variable = "more text"
"Some text, " + variable

will render as Some text, more text

1 Like

Console. Log (‘code ‘) + (‘me-up’)//should return code me-up//
And,
Console.log (‘code’) + (‘ me-up’)//will return the same string results also code me-up//
Correct?

1 Like

Everything should be inside the parentheses.

console.log('code ' + 'me up');

Note there are no uppercase letters in console.

Thanks. Also I have now ingrained in my left hemisphere that syntax matters in JavaScript! So double helix thanks!!$

3 Likes

You’re welcome!

As with most languages, yes, syntax is the foundation of code that can be interpreted. We’re nowadays less focused on good grammar and spelling in our day to day communication, but in programming there is no such laxness permitted if we wish to get the result we planned for.

4 Likes

It doesn’t look like it. I had the same thought, so tested both scenarios, both rendered the expected Hello World. The replies below are all about keeping things bounded by the brackets, rather than directly answering your question. If there’s someone out there with more experience/ knowledge as to why it matters where you add the space, please let us know? Thanks