How will i write a promise function that recursively calls itself? What i ended up is like the one below.
function myPromiseFunction(input) {
return new Promise(function(resolve, reject) {
//compute something with input and got new input so again calling
//myPromiseFunction
if (newInput) {
return myPromiseFunction(new input);
}
else {
resolve(output);
}
});
}
myPromiseFunction(input).then(function(output) {
console.log("completed processing data with input" );
});
Nothing is logged when i run the code. What am i doing wrong here?