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 log(firstName, ...rest) { | |
console.log(firstName); | |
console.log(rest); | |
} | |
log('Marcus', 'Cheese', 'Fruit', 'Blowski', 'Wine'); | |
// Marcus |
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 person = { | |
name: 'Marcus', | |
sayName: function() { | |
var self = this; | |
function changeName() { | |
self.name = 'Anonymous'; | |
console.log(self.name); | |
} | |
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 usingLet() { | |
//i is *not* visible out here | |
var myArray = []; | |
for( let i = 0; i < 5; i++ ) { | |
myArray.push( | |
function() { | |
console.log(i); | |
} | |
); | |
} |
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 makeGreeting(language) { | |
if (language === 'en') { | |
return function(name, lastname) { | |
console.log('Hello ' + name + ' ' + lastname); | |
} | |
} | |
if(language === 'es') { |
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 isPrime(number) { | |
// If your browser doesn't support the method Number.isInteger of ECMAScript 6, | |
// you can implement your own pretty easily | |
if (typeof number !== 'number' || !Number.isInteger(number)) { | |
// Alternatively you can throw an error. | |
return false; | |
} | |
if (number < 2) { | |
return false; |
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 buildFunction() { | |
var arr = []; | |
for (var i = 0; i < 3; i++) { | |
arr.push( | |
(function(j) { | |
return function() { | |
console.log(j); | |
} |
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 myArray = [1,3,2,2,10,9,9,8,7,13,6,4]; | |
var mysteryFunction = function(array) { | |
var hashHadChange; | |
for (var i = 0; i < array.length - 1; i++) { | |
hashHadChange = false; | |
for (var x = 0; x < array.length - 1; x++) { | |
if (array[x] > array[x+1]) { | |
var temp = array[x]; | |
array[x] = array[x+1]; |
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
async.each(myContacts, function(contact, messageToSend, callback) { | |
const message = { | |
from: "+18442849820", | |
to: `+1${contact.number}`, | |
text: messageToSend, | |
callbackUrl: 'https://happie-match.herokuapp.com/messageCallback' | |
}; | |
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
// the paramter called candidatesArray is an array of objects that look about like this: | |
// var candidate = { name: 'Marcus Hurney', phone: '7064834776', email: '[email protected], etc: etc }; | |
// candidatesArray usually contains thousands of objects | |
const sendJobs = (candidatesArray, typeOfReq) => { | |
return new Promise((resolve, reject) => { | |
// array for tracking which jobs have been sent via sms |
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
const sendBandWidthSMS = (number, messageToSend) => { | |
const message = { | |
from: "+18442849820", // <-- This must be a Bandwidth number on your account | |
to: `+1${number}`, | |
text: messageToSend, | |
callbackUrl: 'https://happie-match.herokuapp.com/messageCallback' | |
}; | |
client.Message.send(message) | |
.then(function(message) { |