Amazon Interview Report
- 0of 0 votes
AnswersCreate a basic implementation of Deferred.
- Kevin.Pheasey April 10, 2013 in United States for AWS
Deferred#resolve => Marks the deferred / promise as completed successfully and calls success callbacks
Deferred#reject => Marks the deferred / promise as failed and calls failed callbacks
Deferred#promise => Returns promise object for watching completion
#addCallback => Adds a callback function to be called if the activity is successful
#addFailCallback => Adds a callback function to be called if the activity fails
var promise = myAsyncThingy(); // Call the API that starts some async work and returns a promise
promise.addCallback(function () { console.log("We did it"); }); // Register a success callback
promise.addFailCallback(function () { console.error("We failed"); }); // Register a failure callback
function myAsyncThingy() {
var def = new Deferred(); // Create a deferred to use for managing our async behavior
setTimeout(function () { def.resolve() }, 1000); // In one second call the resolve function to mark it as success
return def.promise(); // return the promise for our deferred to the client
}| Report Duplicate | Flag | PURGE
Amazon Web Developer - 3of 3 votes
AnswersUsing the mythical Hydra as an example, create a button that is destroyed by clicking it, but two new buttons are created in it's place.
- Kevin.Pheasey April 10, 2013 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon Web Developer JavaScript - 2of 2 votes
AnswersCreate a function that will reverse the words in a sentence.
- Kevin.Pheasey April 10, 2013 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon Web Developer JavaScript