This file contains hidden or 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
//Prototypal inhericance uses the the Object.create() syntax, remember this!!!!! | |
let Human = { | |
name: "David", | |
create: function(value){ | |
let instance = Object.create(this); | |
Object.keys(value).forEach(function(key){ | |
instance[key] = value[key]; | |
}) | |
return instance; |
This file contains hidden or 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
let myCurrier = (greeting) => { | |
return (name) => { | |
console.log(`${greeting} ${name}`) | |
} | |
} | |
let instance = myCurrier('Hello'); | |
instance('Jack'); | |
instance('Dave'); |
This file contains hidden or 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
(function() { | |
let tree; | |
function Tree(n) { | |
this.root = null; | |
} | |
Tree.prototype.add = function(val){ | |
let n = new Node(val) | |
if(this.root === null){ |
This file contains hidden or 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
function nbYear(p0, percent, aug, p) { | |
// your code | |
let yearsGrown = 0; | |
let popNow = p0; | |
let amountGrown = ((popNow / 100) * percent) + 50; | |
while(popNow < 1200){ | |
popNow += amountGrown; | |
yearsGrown++; | |
} | |
console.log('population now ', popNow) |
This file contains hidden or 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
function rot13(str) { // LBH QVQ VG! | |
str = str.toUpperCase().split(''); | |
str.reduce(function(acc, item) { | |
var patt = /[a-zA-Z]/g; | |
if(patt.test(item)){ | |
item = item.charCodeAt(0); | |
if(item > 77) { |
This file contains hidden or 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
var myApp = angular.module('myApp', []); | |
myApp.controller('mainController', ['$scope', '$filter', function($scope, $filter) { | |
$scope.handle = ""; | |
$scope.lowerCaseFilter = function() { | |
return $filter('lowercase')($scope.handle); | |
}; |
This file contains hidden or 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
var myApp = angular.module('myApp', []); | |
myApp.controller('mainController', ['$scope', '$filter', function($scope, $filter) { | |
$scope.handle = ""; | |
$scope.lowerCaseFilter = function() { | |
return $filter('lowercase')($scope.handle); | |
}; |
This file contains hidden or 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
//items to count | |
const votes = [ | |
'cow', | |
'sheep', | |
'duck', | |
'cow', | |
'cow', | |
'duck', | |
'pig', | |
'pig', |
This file contains hidden or 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
<body> | |
<div class="container"> | |
<div class="jumbotron"> | |
<div class="container"> | |
<div class="text-center"> | |
<h1> | |
Get a Random Quote | |
</h1> | |
</div> | |
<div id="target"> |
This file contains hidden or 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
ES6: The current version of JavaScript is ES2016 (aka ES7), but a lot of developers still haven’t properly learned ES6. It’s time to learn. | |
Builtin methods: Learn methods for the standard data types (especially arrays, objects, strings, and numbers). | |
Functions & pure functions: You probably think you’ve got a great grasp of functions, but JavaScript has some tricks up its sleeves, and you’ll need to learn about pure functions to get a handle on functional programming. | |
Closures: Learn how JavaScript’s function scopes behave. | |
Callbacks: A callback is a function used by another function to signal when there is a result ready. You say, “do your job, call me when it’s done.” | |
Promises: A promise is a way to deal with future values. When a function returns a promise, you can attach callbacks using the .then() method to run after the promise resolves. The resolved value is passed into your callback function, e.g., doSomething().then(value => console.log(value)); |
NewerOlder