Taking action, whether it’s the first step in learning a new hobby, or moving across the country to your dream city, can be an exciting experience.
Learning how to code and build your website may seem overwhelming at first. You may be thinking, “one forgotten character and my entire code is wrong.” You’re not alone in that thought, but it’s best to simply roll up your sleeves and get started.
HTML defines the content on the web page.
CSS specifies the layout and style of the web page.
Related: JavasScript and Java, while they sound similar, are not the same thing!
React to user actions, mouse clicks, key presses, and mouse movements
Get and set cookies, show messages, ask the visitor questions
Change the existing content and modify styles to HTML
Download and upload files
Send and request data from a server without reloading the page
Photo courtesy of Colourpop.com
Fixed values, or literals, come in various forms. They can be numbers, written with or without decimals, or strings of text, written with double or single quotes.
var blogName = ‘G2 Learning Hub’;
var a = 2; let b = 4; const c = a + b;
It’s common to think of variables like algebra. So in this case, const c would equal 6. The equal sign is used to assign the values to the variables and is referred to as an assignment operator. The plus sign is referred to as an arithmetic operator, which computes values.
When you name your variables, keep in mind these names need to be unique names, which are called identifiers. They can be short names (like a and b) or more descriptive (like age and sum).
When picking names for your variables, or unique identifiers, keep in mind:
Names can contain letters, numbers, underscores, and dollar signs
Names are case sensitive
Names must begin with either a letter, a dollar sign, or an underscore, but not a number
var lastname, lastName; lastname = ‘Jones’; lastName = ‘Smith’;
To do so, I would type:
alert (“Hello, welcome to the G2 Learning Hub”)
In this case, alert is a built-in “action” that translates to the browser to display an alert box, and the text is the string.
When I press enter, I get this popup:
var name = “Mara”
Then, I simply typed name and then hit enter, and it knew my name is Mara. For the alert I typed: alert(name), hit enter and received this popup.
Once I used the code to specify my name and put it in quotes, the code knew that the string for name is Mara.
If I were to try and do an alert for a string I have not yet created or defined, alert (message), I’ll receive an error.
Actions speak louder than words
Mara is a Senior Content Marketing Specialist at G2. In her spare time, she's either at the gym, reading a book from her overcrowded bookshelf, enjoying the great outdoors with her rescue dog Zeke, or right in the middle of a Netflix binge. Obsessions include the Chicago Cubs, Harry Potter, and all of the Italian food imaginable. (she/her/hers)