I hereby claim:
- I am zdfs on github.
- I am zdfs (https://keybase.io/zdfs) on keybase.
- I have a public key ASC_Z5UpU6BxZk4UOO-zMjUtGXhVmAwpd83z_3XuRyk1qgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| // Most of this code is from an answer to a question in | |
| // Rebecca Murphey's JS Assessment project | |
| // https://github.com/rmurphey/js-assessment (thanks, Rebecca!) | |
| Array.prototype.duplicate = function() { | |
| var seen = {}, // Object to keep track of duplicate occurrences | |
| ret = [], // Our return array, with the duplicated values | |
| i, l; // iterator vars |
| Array.prototype.unique = function() { | |
| var unique = {}, // Object to keep track of unique occurrences | |
| ret = [], // Our return array, with unique values | |
| i, l; // iterator vars | |
| for (i = 0, l = this.length; i < l; i+=1) { | |
| // if the unique object already has the current array value, | |
| // skip to the next value of the array |
| function oddsAndEvens(a,b) { | |
| return Math.abs(a % 2) - Math.abs(b % 2) || a - b; | |
| } |
| function findElementsByClass(className) { | |
| var result = [], | |
| elements = document.getElementsByTagName("*"), | |
| classes; | |
| for (var i = 0, ilen = elements.length; i < ilen; i+=1) { | |
| if (elements[i].className !== "") { | |
| classes = elements[i].className.split(" "); | |
| for (j = 0, jlen = classes.length; j < jlen; j+=1) { | |
| if (classes[j] === className) { |
| // Find the index of a number in an array of Fibonacci numbers. | |
| // Return error if number is not a Fibonacci number. | |
| function fibonacci(num) { | |
| var i, | |
| fib = []; // iterator, array | |
| // first two places in the array are always set | |
| fib[0] = 0; |