Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xexi/8bc2570c3066b1ab8dd4311a23d7485b to your computer and use it in GitHub Desktop.
Save xexi/8bc2570c3066b1ab8dd4311a23d7485b to your computer and use it in GitHub Desktop.
Would it be better if i change it to prototype style?
'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