Created
May 28, 2018 21:52
-
-
Save rogerprz/89ef7e26193c77f313cc48c85aac8a6b to your computer and use it in GitHub Desktop.
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
// OOP | |
class GroceryList{ | |
constructor(items){ | |
this.items = items } | |
addItem(item) { | |
this.items.push(item) | |
} | |
} | |
class GroceryItem{ | |
constructor(items){ | |
this.items = items } | |
addItem(item) { | |
this.items.push(item) | |
} | |
} | |
// Functional Programming: | |
function addItem(list, item){ | |
return list.concat(item) | |
} | |
// Creating Data: | |
// OOP | |
var myGroceryList = new GroceryList([ | |
new GroceryItem("banana", 2.99), | |
new GroceryItem("beer",12.99 ), | |
new GroceryItem("apples", 0.98 ) | |
]) | |
// FP | |
const myGroceyList = [ | |
{name: "banana",price: 2.99}, | |
{name: "Beer",price: .99}, | |
{name: "Apples",price: .99} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment