Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html class="no-js">
- <html>
- <head>
- <meta charset="utf-8">
- <title>Javascript</title>
- <meta name="description" content="">
- <meta name="viewport" content="width=device-width">
- <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"/>
- <link rel="stylesheet" href="styles/main.css">
- </head>
- <body>
- <div class="container">
- <div class="jumbotron">
- <h1>Let's Learn Javascript!</h1>
- <p class="lead">...cause Javascript ROCKS.</p>
- </div>
- </div>
- <script src="scripts/main.js"></script>
- </body>
- </html>
- <!-- It's always good to put the script before the body so that it creates a much faster feeling webpage. -->
- -----------------------------------------------------------------------------------------------------------------------------
- /*
- // array of food
- var myList = ['apples', 'oranges', 'bananas'];
- // calling the first item from myList, it's at the 0 index
- alert(myList[0]);
- // defining the 3rd index (4th item) of myList
- myList[3] = 'pineapples';
- alert(myList[3]);
- // changing the first item
- myList[0] = 'watermelon';
- alert(myList[0]);
- */
- /*
- function go()
- {
- alert('hi');
- }
- // we have a string, number, function, then an array of names within myList
- var myList = ['apples', 12, go, ['Will', 'Laura']];
- alert(myList);
- // calling the function go() from myList
- alert(myList[2]);
- */
- /*
- var myList = ['apples', 'oranges', 'bananas'];
- // shifts all of the fruit over thus removing the first index
- myList.shift();
- // apples will not appear since it got shifted
- alert(myList);
- */
- /*
- var myList = ['apples', 'oranges', 'bananas'];
- // removes the last index of your array
- myList.pop();
- // bananas will be gone when alerted
- alert(myList);
- */
- /*
- var myList = ['apples', 'oranges', 'bananas'];
- so what this does is it's going to automatically give you a value and index for each item inside of your list
- and then whatever you do in the function for the value and index it'll effect each and every item
- in it
- myList.forEach(function(value, index)
- {
- console.log(value, index);
- alert('I have ' + value + ' in my shopping bag which is located at index ' + index + ".");
- });
- */
- /*
- WHILE LOOP
- var times = 0;
- while(times < 10)
- {
- console.log("Number: ", times);
- times++;
- }
- */
- /*
- DO WHILE LOOP
- var times = 0;
- do
- {
- console.log("Number: ", times);
- times++;
- } while(times < 10)
- */
- /*
- FOR LOOP
- Basic setup of a for loop
- for (setup, comparison, change)
- {
- }
- for (var i = 0; i < 10; i++)
- {
- console.log("Number: ", i)
- }
- */
- /*
- Using a Loop to output all the items in a Array
- var myList = ['apples', 'oranges', 'bananas'];
- for (var i = 0; i < myList.length; i++)
- {
- alert('I have ' + myList[i]);
- }
- */
- /* NOTES */
- // an Array is a list of items
- // developers in general count from 0
- // functions can be treated like variables due to the way Javascript works
- // arrays can store ANYTHING
- /*
- console.log() prints whatever is in there to the console
- it's basically what you use to print stuff and test things out
- */
- /*
- Loops are ways of looping through things over and over again
- There are 3 types of loops: For, While, and Do
- The only difference between the Do loop and the While loop is that
- the control is at the bottom of Do and for While it's at the top
- */
- -----------------------------------------------------------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment