This has nothing to do with promises, I believe.
Whenever you write a code like this -
function mainFn(callback) {
// do async stuff
// call callback when done
callback();
}
// callback handler
function callbackFn() {
console.log('callback fn');
}
You need to make sure that you pass callback function's reference to the callback parameter of mainFn(), like so -
// Passess reference to callback function inside mainFn
mainFn(callbackFn);
However, doing something like -
// Executes the callback function and passes it's result into mainFn
mainFn(callbackFn());
is totally wrong. This is similar to what you're doing with .then(printstring("C")). It will execute printstring("C") first.
So, to deal with this, wrap it in an anonymous function like so -
function printall() {
printstring("A")
.then(function() { printstring("C"); })
}