Skip to content

Instantly share code, notes, and snippets.

View brendaneamon's full-sized avatar
🤘
Party on, Garth

Brendan Magee brendaneamon

🤘
Party on, Garth
  • Flox
  • London, UK
View GitHub Profile
@brendaneamon
brendaneamon / keybase.md
Created June 21, 2019 23:08
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am brendaneamon on github.
  • I am brendan_eamon (https://keybase.io/brendan_eamon) on keybase.
  • I have a public key ASAhnd2r4rESFuO0fXCw6iPqCage7E9XA4FFofI_HVYF_go

To claim this, I am signing this object:

@brendaneamon
brendaneamon / getFibonacci.js
Last active April 15, 2019 04:46
Get a number from the Fibonacci Sequence by position
'use strict'
function getFibonacciNumber (pos, cache = [1, 1]) {
if (cache[pos - 1]) {
return cache[pos - 1]
}
const next = cache[cache.length - 2] + cache[cache.length - 1]
return getFibonacciNumber(pos, [...cache, next])
@brendaneamon
brendaneamon / getAddendPairs.js
Created April 14, 2019 19:21
A function that takes an array of numbers and a desired sum as parameters and returns all pairs of numbers from the array that add up to that sum
'use strict'
function getAddendPairs(numArray, sum) {
let difference
return numArray.reduce((acc, num) => {
difference = sum - num
if (!acc.map.has(num)) {
acc.map.set(num, true)
}
@brendaneamon
brendaneamon / getMeanMedianMode.js
Created April 14, 2019 18:21
A function that determines mean, media, and mode for an array of numbers
'use strict'
function getMean (numbers) {
return numbers.reduce((acc, num) => {
return acc += num
}, 0) / numbers.length
}
function getMedian (numbers) {
const sorted = [...numbers].sort((a, b) => a - b)