[javascript] Return from a promise then()

I have got a javascript code like this:

function justTesting() {
  promise.then(function(output) {
    return output + 1;

var test = justTesting();

I have got always an undefined value for the var test. I think that it is because the promises are not resolved yet..there is a way to return a value from a promise?

This question is related to javascript promise

The answer is

When you return something from a then() callback, it's a bit magic. If you return a value, the next then() is called with that value. However, if you return something promise-like, the next then() waits on it, and is only called when that promise settles (succeeds/fails).

Source: https://web.dev/promises/#queuing-asynchronous-actions

Similar questions with javascript tag:

Similar questions with promise tag: