Skip to content

Instantly share code, notes, and snippets.

@codingwithrachel
codingwithrachel / prototype.js
Last active February 29, 2016 21:55
prototype
//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;
};
@codingwithrachel
codingwithrachel / while.js
Last active November 30, 2018 15:27
while loop
//spiral
var spiral = function(n){
var direction;
x=0
y=0
resultArray = [[0,0]]
for (var k=1; k < n; k++){
direction = k%2;
@codingwithrachel
codingwithrachel / recursion.js
Last active November 30, 2018 15:27
Recursion
//reverse string
function solution(str){
if(str === "") return "";
return solution(str.substr(1,str.length-1)) + str[0];
}
//fibonacci numbers
function fibonacci(num) {