Last active
August 31, 2017 07:58
-
-
Save xexi/8bc2570c3066b1ab8dd4311a23d7485b to your computer and use it in GitHub Desktop.
Would it be better if i change it to prototype style?
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
'use strict'; | |
var obj = { year: 2017 }; // year is user input | |
function journey(a, cb){ | |
a.country = "go usa"; | |
cb(a); | |
} | |
function journey2(a, cb){ | |
a.person = "meet obama"; | |
if(checkObamaEvent(a.year)){ | |
a.metObama = true; | |
} else { | |
a.metObama = false; | |
} | |
cb(a); | |
} | |
function checkObamaEvent(year){ | |
return year >= 2009 && year <= 2016 | |
} | |
function journey3(a, cb){ | |
if(a.metObama){ | |
a.quote = "Why can't I just eat my waffle?"; | |
} else { | |
a.quote = "There's nothing to tell"; | |
} | |
cb(a); | |
} | |
journey(obj, (a)=>{ | |
journey2(a, (b)=>{ | |
journey3(b, (c)=>{ | |
console.log(JSON.stringify(c)); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment