Last active
December 14, 2015 15:58
-
-
Save jamesmenera/5111655 to your computer and use it in GitHub Desktop.
Homework 1
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
// Exercise 1 - OO || !OO | |
// Define a data structure for cars (make and color), and a function | |
// that logs a string like "I'm a red Mercedes" to the console. | |
// Make two versions: a functional version, and a object-oriented version. | |
//Two solutions, one with a constructor only, and one using prototypes | |
// Example call for functional version: | |
var logCar = function(car) { | |
console.log('I\'m a ' + car.color + ' ' + car.make); | |
} | |
logCar({ make: 'Red', car: 'Ferrari' }); | |
// Example call for OO version: | |
Car = function(color, model){ | |
return console.log('I\'m a ' + color + model'); | |
} | |
(new Car('Ferrari', 'red')).log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment