Day 3
Working on a JS Cheatsheet using a video from Traversy Media.
I should be finished with this tomorrow. I am also spending time working on a website for my first client using the PrestaShop platform.
#CodingPhase #TheCodingWay #365CodingPhaseChallenge
**********
index.html
<!DOCTYPE html>
<html>
<head>
<!-- Cheatsheet created as a code along with a Traversy Media video on YouTube -->
<!-- https://www.youtube.com/watch?v=vEROU2XtPR8&t=323s -->
<title>JavaScript Cheatsheet</title>
<link rel="stylesheet" type="text/css" href="style.css">
<!--
To connect to an external JavaScript file, use the following code
<script src="main.js"></script>
-->
</head>
<body>
<div class="header">
<h1>Learning JaveScript</h1>
<p>With Brad Traversy & Sean Connelly</p>
</div>
<div class="container">
</div>
<div>
<!-- Use <script></script> TAGs when not using external JS file -->
<!-- It is best -->
<script>
alert('Script tags work');
</script>
</div>
<!--
variables can contain:
letters, numbers, underscores, and dollar signs
variable names should begin with a letter
although they can begin with either a _(underscore) or $(dollar sign)
variable names are case sensitive (Test is not the same as test)
-->
<!--
camel case
var myFavoriteNumber
partial case
var MyFavoriteNumber
underscore
var my_favorite_number
-->
<script>
// Number
var number1 = 35;
var number2 = 40;
var number3 = '35';
var number4 = '40';
alert(number1 + number2);
alert(number3 + number4);
alert('My favorite number is ' + number1); //cancontanate string and numeric variables
// End Numbers
// Array
var colors1 = []; //initialized array
var colors1 =['red', 'green', 'blue']; //initialized w/values
alert(colors1); //alert contains all values
alert(colors1[1]); //returns green
// Arrays are 0(zero) based.
// Three values are in positions 0, 1, and 2
// Alternate array declaration
var colors2 = new Array('grey', 'yellow', 'pink');
alert(colors2[2]); //returns pink
// Adding values to the array
colors2[3] = 'orange'; // works for known positions
// A better way to add values
colors2.push('teal'); // Called "dot" syntax
alert(colors2);
var numbers = [5,56,85,124,3,84,'Twenty']; // Values can be mixed
alert(numbers[0] + numbers[3]);
alert(numbers.length);
alert(numbers.sort());
alert(numbers.reverse());
// End Array
//Loops
// for loops
// for(set a variable; set the condition; increment) {
// do something
// }
for (var i = 0; i < 10; i++) {
console.log(i);
}
var w = 0;
while(w < 10) {
console.log(w);
w++;
}
var digits = [55,84,95,221,2,8,665,35,44];
digits.forEach(function(number){
console.log(number);
});
//End Loops
// String
// Object
// Conditionals
// End Conditionals
</script>
</body>
</html>
**********
style.css
body {
text-align: center;
font-family: sans-serif;
font-size: 18px;
}
li {
list-style: none;
line-height: 2em;
text-align: left;
}
.header {
background: #f4f4f4;
border-bottom: #ccc 3px solid;
padding: 20px;
}
.container {
width: 700px;
margin: 30px auto;
}
I should be finished with this tomorrow. I am also spending time working on a website for my first client using the PrestaShop platform.
#CodingPhase #TheCodingWay #365CodingPhaseChallenge
**********
index.html
<!DOCTYPE html>
<html>
<head>
<!-- Cheatsheet created as a code along with a Traversy Media video on YouTube -->
<!-- https://www.youtube.com/watch?v=vEROU2XtPR8&t=323s -->
<title>JavaScript Cheatsheet</title>
<link rel="stylesheet" type="text/css" href="style.css">
<!--
To connect to an external JavaScript file, use the following code
<script src="main.js"></script>
-->
</head>
<body>
<div class="header">
<h1>Learning JaveScript</h1>
<p>With Brad Traversy & Sean Connelly</p>
</div>
<div class="container">
</div>
<div>
<!-- Use <script></script> TAGs when not using external JS file -->
<!-- It is best -->
<script>
alert('Script tags work');
</script>
</div>
<!--
variables can contain:
letters, numbers, underscores, and dollar signs
variable names should begin with a letter
although they can begin with either a _(underscore) or $(dollar sign)
variable names are case sensitive (Test is not the same as test)
-->
<!--
camel case
var myFavoriteNumber
partial case
var MyFavoriteNumber
underscore
var my_favorite_number
-->
<script>
// Number
var number1 = 35;
var number2 = 40;
var number3 = '35';
var number4 = '40';
alert(number1 + number2);
alert(number3 + number4);
alert('My favorite number is ' + number1); //cancontanate string and numeric variables
// End Numbers
// Array
var colors1 = []; //initialized array
var colors1 =['red', 'green', 'blue']; //initialized w/values
alert(colors1); //alert contains all values
alert(colors1[1]); //returns green
// Arrays are 0(zero) based.
// Three values are in positions 0, 1, and 2
// Alternate array declaration
var colors2 = new Array('grey', 'yellow', 'pink');
alert(colors2[2]); //returns pink
// Adding values to the array
colors2[3] = 'orange'; // works for known positions
// A better way to add values
colors2.push('teal'); // Called "dot" syntax
alert(colors2);
var numbers = [5,56,85,124,3,84,'Twenty']; // Values can be mixed
alert(numbers[0] + numbers[3]);
alert(numbers.length);
alert(numbers.sort());
alert(numbers.reverse());
// End Array
//Loops
// for loops
// for(set a variable; set the condition; increment) {
// do something
// }
for (var i = 0; i < 10; i++) {
console.log(i);
}
var w = 0;
while(w < 10) {
console.log(w);
w++;
}
var digits = [55,84,95,221,2,8,665,35,44];
digits.forEach(function(number){
console.log(number);
});
//End Loops
// String
// Object
// Conditionals
// End Conditionals
</script>
</body>
</html>
**********
style.css
body {
text-align: center;
font-family: sans-serif;
font-size: 18px;
}
li {
list-style: none;
line-height: 2em;
text-align: left;
}
.header {
background: #f4f4f4;
border-bottom: #ccc 3px solid;
padding: 20px;
}
.container {
width: 700px;
margin: 30px auto;
}
Comments
Post a Comment