Skip to content

Instantly share code, notes, and snippets.

View BlessYAHU's full-sized avatar
💻

A'braham Barakhyahu BlessYAHU

💻
View GitHub Profile
@BlessYAHU
BlessYAHU / gist:636701
Created October 20, 2010 15:59
functional_vs_OO
// Exercise 1 - OO || !OO
// Define a data structure for cars (make and color), and a function
// that logs a string like "I'm a red Mercedes" to the console.
// Make two versions: a functional version, and a object-oriented version.
function logCar(params) {
if(params && params.color && params.make) {
console.log("I'm a " + params.color + " " + params.make );
}
}
@BlessYAHU
BlessYAHU / gist:636700
Created October 20, 2010 15:58
03-Skinning_cats
// Implement a number Prototype function for repeating strings.
// (4).times('test') --> 'testtesttesttest'
// Example in functional programming:
function repeatString(string, times){
var result = '';
while(times--) result += string;
return result;
}
@BlessYAHU
BlessYAHU / exercise 2 - redux
Created October 19, 2010 18:01
Exercise 2
var countdown = (function() {
var index;
function log(){
console.log(index);
}
function iterate(){
log();
if(index>1) setTimeout(iterate, 1000);