I am unable to move on from this lesson without getting the solution from the help menu! It seems simple so I don’t know if I am missing something or if it is just a bug.
I am using Firefox. I reopened it, copied the solution, and pasted it. It wouldn’t allow the pasted solution to proceed either. I think it must be a bug on my end somewhere.
That is not the objective of this module. It’s more about concepts than actual code. You might glean a lot from the HTML and CSS but it would be ahead of the learning curve and you would have more questions than answers, which questions if they do not get answered force you into presumptions.
Bottom line, don’t try to get ahead of the curve, just yet.
I notice in these early examples you’re not declaring variables with var. I know I’m getting way ahead of myself – but is this not the proper convention anymore?
Declaring variables is less convention and more intrinsic requirement. In the global namespace a declaration is rather moot, though. For small exercises most of the activity takes place there. Declared or not, variables are all global, in the var sense.
In ES5, var gave variables function scope which prevented them from leaking out into the global namespace. In ES6, let and const give variables block scope which prevents them from leaking into their local scope.
This is vitally important since now it means that even in the global namespace, variables can exist in their own block scope and not collide with global variables. It has relegated var to a legacy keyword that might even one day be deprecated.
There is no such thing as bad coding, unless it doesn’t work, or doesn’t work correctly all the time. Not having spaces around operators still works. The only thing is it is harder to spot the operators when reading the code.
Style guides generally recommend whitespace around operators. Nothing is said about it making the code better, or not bad. It’s just easier to read and debug.
// declare variable one
// set it equal to the value 'grass'
This means that we should first declare a variable with the name one. Then we should assign one the value of 'grass'. We declare and initialize variables by using the assignment operator, =.
For example:
greeting = 'Hello world!'
Here, 'grass' is a string and it is assigned to the variable one. Strings are a data type you will learn more about in an upcoming lesson and, in many programming languages, should always be surrounded by either a pair of 's or "s (or either), depending on the language you are using.