So, I have this code about an object
Obj.prototype.save = function (fn){
var aabb = Obj.reEditName(this.name, function(newName) {
return newName;
// I also try the following
var foo = newName;
return foo;
});
console.log("aabb is : "+aabb);
}
Obj.reEditName = function(name, fn){
var name ? name : "TestingName";
nameEditor(name,function(err, finalName) {
return fn(finalName);
});
}
Obj.reEditName
works fine and I get a value back that I can get from newName
.
But console.log("aabb is : "+aabb);
gives back undefined.
I dont get why. I get a value and I return it, and aabb
suppose to catch it. Why this isnt working? How I can pass newName
back to aabb
?
Thanks