This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (…And the good!) assignment | |
// Dr. Steven B. Combs, coding novice | |
for (var x = 1; x < 21; x++){ | |
if (x % 3 === 0 && x % 5=== 0){ // If number divisible by 3 and 5 | |
console.log("FizzBuzz"); // Print 'FizzBizz' | |
} | |
else if (x % 3 === 0){ // If number divisible by 3 | |
console.log("Fizz"); // Print 'Fizz' to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Object Formatting Syntax | |
// Both code examples create the same object | |
// Dr. Steven B. Combs, coding novice | |
// Object Literal Notation | |
var me = { | |
name: 'Steven', | |
age: '48', | |
interests: ["coding", "running", "blogging"], // array | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Arrays | |
// Dr. Steven B. Combs, coding novice | |
// Define array | |
var languages = ["HTML", "CSS", "JavaScript", "Python", "Ruby"]; | |
console.log(languages[2]); // Print third item in array | |
console.log(languages.length); // Print number of items in array | |
// Print contents of array a line at a time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Divisible by Two, or any other value, Javascript function code | |
// Dr. Steven B. Combs, coding novice | |
var isDivisible = function(number) { | |
if (number % 2 === 0) { // Number 2 could be any value | |
return true; // Return true if value is divisible by 2 | |
} else { | |
return false; // Return false if value is not divisible by 2 | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Dragon Slayer!) assignment | |
// Dr. Steven B. Combs, coding novice | |
var slaying = true; | |
var youHit = Math.floor(Math.random() * 2); // random number between 0 and 1 | |
var damageThisRound = Math.floor(Math.random() * 5 + 1); // random number between 1 and 5 | |
var totalDamage = 0; // damage counter | |
while (slaying){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (When to 'while' and when to 'for') assignment | |
// Dr. Steven B. Combs, coding novice | |
// For loop - use to repeat code a specific number of times | |
for(var i = 0; i < 3; i++){ | |
console.log("Hello World!"); | |
} | |
// While loop - use to repeat code until a specific condition is met |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<link type="text/css" rel="stylesheet" href="stylesheet.css"/> | |
<title>Result</title> | |
</head> | |
<body> | |
<div id="header"></div> | |
<div class="left"></div> | |
<div class="right"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A Codecademy Web Fundamentals (CSS Selectors) assignment | |
Dr. Steven B. Combs, coding novice */ | |
.fancy { | |
font-family: cursive; | |
color: violet; | |
} | |
#serious { | |
font-family: Courier; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Search Text For Name) assignment | |
// Dr. Steven B. Combs, coding novice | |
var text = "blah blah blah blah Steven \ | |
blah blah blah blah Steven blah"; | |
var myName = "Steven"; | |
var hits = []; | |
for (var i = 0; i < text.length; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript Getting Started with Programming | |
// A Codecademy Javascript (Loops and Arrays III) assignment | |
// Dr. Steven B. Combs, coding novice | |
// Assign array and variable | |
var array = [3, 6, 2, 56, 32, 5, 89, 32]; | |
var largest = 0; | |
for (var i = 0; i < array.length; i++){ // Parse through array a single value at a time | |
if (array[i] > largest) { // Determine if the array element is larger than the last |