Welcome to the Treehouse Community
Looking to learn something new?
nick beck3,625 Points
how come you don't the parentheses, in the first sentence variable?
i notice that on the first sentence variable, there are no parentheses used. why not ?
Sean T. Unwin28,672 Points
If you are referring to the variable,
var sentence = '<h2>There once was a " + adjective;
it is because we don't put quotes around variables and since
adjective, in this case, is a String and so is
I hope that my wording was not too confusing.
In simple terms to what Sean is saying.
var adjective = prompt ('Please type an adjective'); Here we are asking the person to type the adjective variable.
var sentence = "<h2>There once was a " + adjective; Here is a new variable named sentence which adds the first string "<h2>There once was a " to the variable adjective which is not a string. I look back and review the "String and Numbers" video.
Regarding the parentheses it doesn't matter what you use whether it be '' or "" You just need to be consistent and use them appropriately.
Hope that helps!
Samantha AtkinsonFront End Web Development Techdegree Student 36,775 Points
The reason why there are no parentheses for the variable named sentence is because the value is simply a string with no command or methods attach to it and the results from your previous variable named adjective prompt added on. Parentheses are used for methods for example: alert('You have done well!'); or document.write ('Have a nice day');. Methods are actions, alert opens a dialog box in your browser and document.writes writes text to your web page.
Hope this makes it a little clearer.