diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/class1.html b/class1.html deleted file mode 100644 index 2414837..0000000 --- a/class1.html +++ /dev/null @@ -1,704 +0,0 @@ - - - -
- - -
- While we wait to get started, please ensure you have the following set up:
-Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
-Some "rules"
-Let's get to know eachother
-How your computer accesses websites
-
- JavaScript is "client side"
-Your browser understands it!
-
- alert('Hello');
-
- Variables hold content
-Words, numbers, true/false, basically any kind of content
-Declare a variable (Give it a name)
-
- var bananas;
-
- Initialize variable (Give it a value)
-
- bananas = 5;
-
- Declare and initialize at the same time!
-
- var bananas = 5;
-
- Change value of variable
-
- bananas = 4;
-
- (I ate a banana)
-string -- a group of characters in quotes
-
- var fruit = "banana";
-
- number -- (well, a number)
-
- var pi = 3.14;
- var year = 2013;
- var bananaTally = 200;
-
- boolean -- yes or no
-
- var skyIsBlue = true;
- var grassIsPink = false;
-
- undefined -- no value yet
-
- var favoriteDinosaur;
-
- null -- a purposely empty value (not the same as 0)
-
- var myTigersName = null;
-
- Begin with a letter, _, or $
-Contain letters, numbers, _ and $
-
- var hello;
- var _hello;
- var $hello;
- var hello2;
-
- Names are case sensitive
-
- var hello;
- var Hello;
- var heLLO;
-
- Math-y expressions!
-
- var bananas = 5;
- var oranges = 2;
- var fruit = bananas + oranges;
-
- | Symbol | Meaning |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus |
| ++ | Increment |
| -- | Decrement |
Word-y expressions!
-
-var name = "Mitch";
-var dinosaur = "Stegosaurus";
-var sentence = "My dinosaur is a " + dinosaur + ". It's name is " + name + ".";
-
- Create a new html file
-
-<html>
- <head>
- <title>My Site!</title>
- </head>
- <body>
- My site!
- </body>
-</html>
-
- Create a new javascript file (a file that ends in .js)
-Link it to your html file
-
-<html>
- <head>
- <title>My Site!</title>
- <script src="javascript.js"></script>
- </head>
- <body>
- My site!
- </body>
-</html>
-
- Life time supply calculator
-Ever wonder how much a lifetime supply of your favorite snack or drink is?
-
- alert(answer);
-
-
-
- Javascript can run through code based on conditions
-
- if (condition here){
- // statement to execute
- }
-
-
- var bananas = 1;
- if (bananas < 2){
- console.log("You should buy more bananas!")
- }
-
-
- // comment on one line
- /* comment on
- multiple lines
- */
-
- | === | Equality |
| !== | Inequality |
| > | Greater than |
| >= | Greater than or equal to |
| < | Less than |
| <= | Less than or equal to |
Don't confuse = (assign a value)
with === (compare a value)
| && | AND |
| || | OR |
| ! | NOT |
- var bananas = 5;
- var oranges = 2;
- if (bananas > 3 && oranges > 3){
- console.log('Eat fruit!');
- }
- if (bananas < 2 || oranges < 2){
- console.log('Buy fruit!');
- }
- if (!(bananas >= 0)){
- console.log('How do you have negative bananas?');
- }
-
- You can use else to perform an alternative action if the "if" fails
-
- var bananas = 5;
- if (bananas > 3){
- console.log('Eat a banana!');
- } else {
- console.log('Buy a banana!');
- }
-
- You can use else if to have multiple choices
-
-var age = 20;
-if (age >= 35) {
- console.log('You can vote AND hold any place in government!');
-} else if (age >= 25) {
- console.log('You can vote AND run for the Senate!');
-} else if (age >= 18) {
- console.log('You can vote!');
-} else {
- console.log('You have no voice in government (yet)!');
-}
-
- Add an if/else statement to our lifetime supply calculator so that if the lifetime supply is greater than 40,000, you say "Wow! That's a lot!" otherwise, say "You seem pretty reasonable!"
-Functions are re-usable collections of statements
-
- function sayHi(){
- console.log('Hi!');
- }
-
-
- sayHi();
-
- Functions can take named arguments
-
- function sayHi(name){
- console.log('Hi' + name + '!');
- }
- sayHi('Mitch, the dinosaur');
- sayHi('Harold, the hippo');
-
- var name = 'Pip, the mouse';
- sayHi(name);
-
- Functions can take MULTIPLE named arguments
-
- function addNumbers(num1, num2){
- var result = num1 + num2;
- console.log(result);
- }
-
- addNumbers(5, 6);
-
- var number1 = 12;
- var number2 = 15;
- addNumbers(number1, number2);
-
- Functions can return a value
-
- function addNumbers(num1, num2){
- var result = num1 + num2;
- return result; //Anything after this line won't be read
- }
- var sum = addNumbers(5, 6);
-
- JavaScript have "function scope". They are visible in the function where they are defined
-
- function addNumbers(num1, num2){
- var result = num1 + num2;
- return result; //Anything after this line won't be read
- }
- var sum = addNumbers(5, 6);
- console.log(result); //will return undefined because result only exists inside the addNumbers function
-
- JavaScript have "function scope". They are visible in the function where they are defined
-
- var result;
- function addNumbers(num1, num2){
- result = num1 + num2;
- return result; //Anything after this line won't be read
- }
- var sum = addNumbers(5, 6);
- console.log(result); //will return 11 because the variable was defined outside the function
-
- Wrap the lifetime supply calculator in a function called calculate()
-Add a link to the html that calls the function when it is clicked
-
- <a href = "#" onclick="calculate()">
- Calculate life time supply
- </a>
-
-
- Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.
-Some "rules"
-Sometimes you want to go through a piece of code multiple times
-Why?
-The while loop tells JS to repeat statements while a condition is true:
-
- while (expression) {
- // statements to repeat
- }
-
-
- var x = 0;
- while (x < 5) {
- console.log(x);
- x++;
- }
-
- What happens if we forget x++;?
-The loop will never end!!
-The for loop is a safer way of looping
-
- for (initialize; condition; update) {
- // statements to repeat
- }
-
-
- for (var i = 0; i < 5; i++) {
- console.log(i);
- }
-
- An array is a data-type that holds an ordered list of values, of any type:
-
- var arrayName = [element0, element1, ...];
-
-
-var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
-var favoriteNumbers = [16, 27, 88];
-var luckyThings = ['Rainbows', 7, 'Horseshoes'];
-
-
- console.log(rainbowColors.length);
-
- You can access items with "bracket notation".
-
- var arrayItem = arrayName[indexNum];
-
-
- var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
- var firstColor = rainbowColors[0];
- var lastColor = rainbowColors[6];
-
-
- var awesomeAnimals = ['Corgis', 'Otters', 'Octopi'];
- awesomeAnimals[0] = 'Bunnies';
-
-
- awesomeAnimals[4] = 'Corgis';
-
-
- awesomeAnimals.push('Ocelots');
-
-
-var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
-for (var i = 0; i < rainbowColors.length; i++) {
- console.log(rainbowColors[i]);
-}
-
- Objects are a data type that let us store a collection of properties and methods.
-
- var objectName = {
- propertyName: propertyValue,
- propertyName: propertyValue,
- ...
- };
-
-
- var charlie = {
- age: 8,
- name: "Charlie Brown",
- likes: ["baseball", "The little red-haired girl"],
- pet: "Snoopy"
- };
-
- Access values of "properties" using "dot notation":
-
- var charlie = {
- age: 8,
- name: "Charlie Brown",
- likes: ["baseball", "The little red-haired girl"],
- pet: "Snoopy"
- };
-
-
- var pet = charlie.pet;
-
-
- var name = charlie['name'];
-
-
- var gender = charlie.gender
-
- Use dot or bracket notation with the assignment operator to change objects.
-
- charlie.name = "Chuck";
-
-
- charlie.gender = "male";
-
-
- delete charlie.gender;
-
- Arrays can hold objects too!
-
- var peanuts = [
- {name: "Charlie Brown",
- pet: "Snoopy"},
- {name: "Linus van Pelt",
- pet: "Blue Blanket"}
- ];
-
-
- for (var i = 0; i < peanuts.length; i++) {
- var peanut = peanuts[i];
- console.log(peanut.name + ' has a pet named ' + peanut.pet + '.');
- }
-
- You can pass an object into a function as a parameter
-
- var peanut ={
- name: "Charlie Brown",
- pet: "Snoopy"
- };
-
-
- function describeCharacter(character){
- console.log(character.name + ' has a pet named ' + character.pet + '.');
- }
-
-
- describeCharacter(peanut);
-
-
- On every webpage, the document object gives us ways of accessing and changing the DOM.
-Every DOM "node" has properties. They are connected like a family tree.
-Parent (parentNode), children (childNodes, firstChild), siblings (prevSibling, nextSibling)
-
- var bodyNode = document.body; // <body>
- var htmlNode = document.body.parentNode; // <html>
- for (var i = 0; i < document.body.childNodes.length; i++) {
- var childNode = document.body.childNodes[i];
- //could be <p>, <h1>, etc.
- //any html element
- }
-
- Finding every element on the page by siblings and children is time consuming!
-The document object also provides methods for finding DOM nodes without going one by one
-
-<img id="mainpicture" src="http://girldevelopit.com/assets/pink-logo.png">
-
-
-var img = document.getElementById('mainpicture');
-
-
- <li class="peanut">Charlie Brown</li>
- <li class="peanut">Linus van Pelt</li>
-
-
- var listItems = document.getElementsByTagName('li');
- for (var i =0; i < listItems.length; i++) {
- var listItem = listItems[i];
- }
-
-
- var img = document.getElementById('mainpicture');
-
- We can use node methods to set and retrieve attributes
-
- var img = document.getElementById('mainpicture');
- img.getAttribute('src');
- img.setAttribute('src', 'http://girldevelopit.com/assets/pink-logo.png');
-
-
-
- var img = document.getElementById('mainpicture');
- img.getAttribute('class');
- img.setAttribute('class', 'picture-class');
-
- Each DOM node has an innerHTML property:
-
- document.body.innerHTML;
-
-
-document.body.innerHTML = '<p>I changed the whole page!</p>';
-
-
-document.body.innerHTML += "...just adding this bit at the end of the page.";
-
- The document object can create new nodes:
-
- document.createElement(tagName);
- document.createTextNode(text);
- document.appendChild();
-
-
-var newImg = document.createElement('img');
-newImg.src = 'http://girldevelopit.com/assets/pink-logo.png';
-document.body.appendChild(newImg);
-
-
-var newParagraph = document.createElement('p');
-var paragraphText = document.createTextNode('New Paragraph!');
-newParagraph.appendChild(paragraphText);
-document.body.appendChild(newParagraph);
-
-