Skip to content

Instantly share code, notes, and snippets.

Steven B. Combs' Git stevencombs

Block or report user

Report or block stevencombs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CustomizingConstructors.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Customizing Constructors) assignment
// Dr. Steven B. Combs, coding novice
// This format requires three lines to create a Book object
var harry_potter = new Object();
harry_potter.pages = 350;
harry_potter.author = "J.K. Rowling";
// This format requires a single line to create a Book object
View TryItOut.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Try it Out!) assignment
// Dr. Steven B. Combs, coding novice
// Our person constructor
function Person (name, age) {
this.name = name;
this.age = age;
}
View LoopTheLoop.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Loop the loop) assignment
// Dr. Steven B. Combs, coding novice
// Person constructor
function Person(name,age) {
this.name=name;
this.age=age;
}
View ConstructorsReviewRabbits.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Constructors in Review - Rabbits) assignment
// Dr. Steven B. Combs, coding novice
// Define Rabbit adjective constructor
function Rabbit(adjective) {
this.adjective = adjective;
this.describeMyself = function() {
console.log("I am a " + this.adjective + " rabbit");
};
View MoreKindsMethods.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (More Kinds of Methods) assignment
// Dr. Steven B. Combs, coding novice
var square = new Object(); // Create 'square' object
square.sideLength = 6; // Set square side length 6
square.calcPerimeter = function() { // Calculate perimeter function
return this.sideLength * 4; // Return value of the perimeter method
};
square.calcArea = function() { // Calculate area function
View MakeYourOwnMethod.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Make Your Own Method) assignment
// Dr. Steven B. Combs, coding novice
var rectangle = new Object(); // New object 'rectangle'
rectangle.height = 3; // Rectangle height 3
rectangle.width = 4; // Rectangle width 4
rectangle.setHeight = function (newHeight) { // Set rectangle height function
this.height = newHeight; // Use 'this' as placeholder to modify object called
View MethodExample.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Make Your Own Method) assignment
// Dr. Steven B. Combs, coding novice
var setAge = function (newAge) { // New function
this.age = newAge; // Use this as a method placeholder for the function
};
var bob = new Object(); // New object 'bob'
bob.age = 30; // Set 'bob' age
View FunctionMultiply.js
// Javascript Getting Started with Programming
// A Codecademy Javascript (Function Review) assignment
// Dr. Steven B. Combs, coding novice
var multiply = function (x, y) { // Create function with two inputs
return x * y; // Multiply x and y and return the value
};
multiply (10, 10); // Call the function and pass off two values
View FizzBuzz.js
// 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
@stevencombs
stevencombs / JavascriptObjectConstructor.js
Last active Dec 22, 2015
Javascript Object Formatting
View JavascriptObjectConstructor.js
// 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
};
You can’t perform that action at this time.