Dot, DAsh, Slash, and the likes. What's going on here 🧐?

Hi everyone,

I just read something rather confusing.

In HTML, I learned that /* ............*/ was a CSS “comment”, and this :<!--.......--> was an HTML "comment.

Now, I just read that in JavaScript this /*..........*/ is a JavaScript comment. So is this just a JavaScript comment, or a CSS comment, or both?

More than that, I just read that the double // means: to ignore the rest of the text after it. So does that mean that in JavaScript when one types an address in the address bar, the double // is telling JavaScript to ignore something, for example this address here: [Preformatted text](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code) and what are all these slashes after slashes for???

In addition, I learned in HTML that a dash is used to represent space between two words. However, many instances in CSS I was asked to code something and where I thought that I would be required to add a dash for the space between the words, and Iwasn’t asked to. This kind of confuses me a bit because I am not sure when I am and when I am not supposed to use a dash, ex: (my-cats-and-my-dogs) or (my cats and my dogs). Very confusing!!

Finally, I want to know why we use double(//), dot(.), one slash(/), and dash or dashes (-) in this code universe? If I am not mistaken, dash(-) supposed to represent space between words, so what do the others that I just mentioned stand for or represent.

Please explain in human English. Thank you very much.

both

it is an option if you want:

// comment out the whole single line of JS code

or

const IamNotcommented = 'stuff' // make the comment on the line, but you do not want the whole line to be commented

this stuff is not about comments in JS or CSS or else, it is URL address

that would be more convinient to discuss if you will provide some examples of such things, and then we’ll break it down

code universe - I assume you are talking about coding in general. There are bunch of languages, and each one has own syntax rules.
For example, dot.
you can use it in CSS for class selectors, and in JS you will use dot for accessing object properties.

OMG, how did you make my original text dropdown like that?? Each of your section has a little dropdown on the right top corner. It’s so cool.

Anyway, thank you for your answer. I appreciate the detail explanation. I will get back to you with the section where I wasn’t asked to put the dash when I thought that I should. Just give me a minute to go back and search all my previous challenges.

Ok. One more question, and I will leave you at peace.
I am just reading this assignment about var.

var ourName;
creates a variable called ourName. In JavaScript we end statements with semicolons. Variable names can be made up of numbers, letters, and $ or _, but may not contain spaces or start with a number.

Use the var keyword to create a variable called myName.

Hint
Look at the ourName example above if you get stuck.

When I type var myName, I pass the challenge. However, if I type: var myname;, I get this: // running tests You should declare myName with the var keyword, ending with a semicolon // tests completed

why is switching the capital (N) for a lowercase (n) create such a big difference? Please explain.

Thank you

you can select the chunk of text which you want to quote, and the option quote will pop up

for machine, ourName and ourname are not the same thing.
when you are going through challenges here, your code is evaluated by automatic test suite, so in order to pass the tests you should follow instructions of the challenge

looks like for this one test suite is forgiving about semicolon(in JS you can write code w/out semicolon and it will work, but it is still better to write those where it is needed)
but for variable name itself test suite is pretty much strict here, so ourName is the only option.

if talking about naming in general, you can name your variable ourname of course, and your code will work
however, there is a convention to use so-called camel case for naming variables in JavaScript,

so,

thisIsMyVariable - camel case, will work, good practice
thisismyvariable - not camel case, will work still, but not very good practice

EDIT. I am correcting the original post. I made a mistake in original post by confusing camel and snake case. For details see the below conversation.

Wicked!!! :smiling_imp:

Thank you very much for furnishing such clear explanation. Good job!!

Small correction. :slight_smile:
This one would be camel case

Snake case is more popular in Python :+1:

this_is_a_variable
1 Like

yes, that was a mistake, thanks!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.