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
| //All, none, any | |
| Array.prototype.all = function (p) { | |
| return this.length > 0 && this.filter(p).length === this.length; | |
| }; | |
| Array.prototype.none = function (p) { | |
| return this.filter(p).length === 0; | |
| }; |
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
| //spiral | |
| var spiral = function(n){ | |
| var direction; | |
| x=0 | |
| y=0 | |
| resultArray = [[0,0]] | |
| for (var k=1; k < n; k++){ | |
| direction = k%2; |
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
| //reverse string | |
| function solution(str){ | |
| if(str === "") return ""; | |
| return solution(str.substr(1,str.length-1)) + str[0]; | |
| } | |
| //fibonacci numbers | |
| function fibonacci(num) { |
NewerOlder