Last active
November 10, 2017 15:43
-
-
Save noelleleigh/e5025210ba0ea9584a67754a63a1e282 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
function makeGraphBase(width, height) { | |
return Array(height).fill(undefined).map(row => Array(width).fill('⬜')); | |
}; | |
function makeData() { | |
return [0, 1, 2, 4, 4, 3]; | |
}; | |
function diff(val, index, array) { | |
return array[index + 1] - val; | |
}; | |
/** Return an array with one fewer elements */ | |
function getSlopes(data) { | |
return data.map(diff).filter(val => !isNaN(val)); | |
}; | |
function normalizeSlopes(slopes) { | |
return slopes.map((slope) => { | |
if (slope > 0) { | |
return 1 | |
} else if (slope < 0) { | |
return -1 | |
} else { | |
return 0 | |
}; | |
}); | |
}; | |
function cleanupSlopes(slopes) { | |
const noZeroes = slopes.filter(val => val !== 0); | |
const bigSlopes = noZeroes.map(diff) | |
}; | |
console.log('hey ⬜📈📉'); | |
console.log(makeGraphBase(10, 5)); | |
console.log(makeData()); | |
console.log(getSlopes(makeData())); | |
console.log(normalizeSlopes(getSlopes(makeData()))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment