Skip to content

vithyasrikumar/day-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

First Things First

Showcase

Reminder The 3 Steps of updating your Git repository

  1. git add .
  2. git commit -m "this is a descriptive commit message"
  3. git push origin master

Asking for Help

  1. Ask Google
  2. Ask your neighbor
  3. Ask Nabil or Sean

Clone into this repository

In your terminal, in your code-forward directory:

git clone https://github.com/code-forward/day-2.git

Introduction to JavaScript

JavaScript is the programming language of the web. Although it's capable of so much more, today we'll focus on how it can be used to add interactivity to your webpages.

All our languages Basically how it works.

There are multiple ways to do this, but for now, we'll link Javascript files to our webpages by like this:

<!doctype html>
<html>
  <head>
    <title></title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <div>
      <h1>Hello, Gakko!</h1>
      <p></p>
    </div>
    <script type="text/javascript" src="script.js"></script>
  </body>
</html>

This way, since <script></script> is at the bottom of the <body></body>, all the content of the webpage will be loaded before we run our JavaScript program.

But first let's see what JavaScript can do.

Open your Chrome Developer Tools and find the Console. Run a few of these commands.

It can make alerts

alert("NOOOOO!!!!");

It can print words on the Console

console.log("Hello, world!");

It can do math

1 + 2 + 3 + 5 + 8 + 13 + 21 + 34

It can modify content

document.querySelector('body').textContent = "New Title";

We're pretty much telling the browser, "Hey, document! Select an h1, and change its text to say 'New Title'."

See if you can change the title of the New York Times food section.

You'll need to relaunch Developer Tools for this specific webpage.

It can change styles

In other words, we can write CSS with JavaScript!

document.querySelector('div').style.background = "red";

We're telling the browser, "Hey, document! Select a div, and change its style (its CSS) so its background property is red."

Important note: JavaScript syntax is slightly different from CSS. For example:

body {
  text-transform: uppercase; 
}

accomplishes the same thing as

document.querySelector('body').style.textTransform = "uppercase";

The key difference is text-transform in CSS vs textTransform in JS

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published