I don't know what's wrong with this code, please help

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

var MyName; Allison;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Challenge: Declare JavaScript Variables

Link to the challenge:

You are close.

Remove the Allison and lowercase the My. Later on, you will learn how to give variables value with different data types such as a string, number, object (more advanced), etc.

I’ll spoil a little.

var myName = "Allison"

This would be the correct way to store a name to a variable. It is called a string and is used for text. If you just say Allison without quotes, your telling JavaScript to look for a variable named Allison and use its assigned value, which in this program, does not exist.

Javascript follows a convention of using camelCase . The first word of the variable starts with a lower case letter and the first letter of the words following it start with capital letters - if the variable name contains more than one word.

var thisIsCamelCase;

If the variable has only 1 word, that also will be in full lower case.

var word;

Yes, the code will work even if it starts with a capital letter but it is good practice to use camelCase while using variables.

There are cases where the variable might be fully upper cased but thats another story :slight_smile:

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