Skip to content

Instantly share code, notes, and snippets.

View selfup's full-sized avatar
💻
doing the most

Regis Boudinot selfup

💻
doing the most
View GitHub Profile
var names = [
["John", "Brown"],
["Lisa", "May"],
["Henry", "Ford"],
];
function displayLastName(inputName) {
// first we are going to map through the names array
// return null for anything that doesn't match
return names
const fib = (num, cache = {}) => (num < 2)
? num
: cache[num] || Object
.assign(cache, { [num]: (fib(num - 1, cache) + fib(num - 2, cache)) })
[num];
function fib(n, cache) {
cache = cache || {};
if (n < 2) {
return n;
} else {
if (cache[n]) {
return cache[n]
} else {
cache[n] = fib(n - 1, cache) + fib(n - 2, cache);
return Object.assign(
{}, // << this is the important part - LOOK HERE!
cache,
{ [num]: (fib(num - 1, cache) + fib(num - 2, cache)) },
)[num];
cache[n] = fib(num - 1, cache) + fib(num - 2, cache);
return cache[n];
const fib = (num, cache = {}) => {
if (num < 2) return num;
// if the cached result exists, return the cached result
if (cache[num]) return cache[num];
// otherwise, create a new entry in the cache with the new result
return Object.assign(
cache,
{ [num]: (fib(num - 1, cache) + fib(num - 2, cache)) },
)[num];
// ^^ and return the result so recursion can continue
def fib(n)
return n if n < 2
# ruby has implicit returns
# so no need to say return on the last line here
fib(n - 1) + fib(n - 2)
end
def memo_fib(n, cache = {})
return n if n < 2
function fib(number) {
if (number < 2) return number;
return (fib(number - 1) + fib(number - 2));
}
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..42f7332
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
{
"name": "windows-aliases",
"version": "1.0.0",
"description": "",
"main": "",
"dependencies": {},
"devDependencies": {},
"scripts": {
"bash": "bash.exe -cur_console:p",
"test": "echo \"Error: no test specified\" && exit 1"