How to handle multiple return statements I am trying to restructure a function more clearly and readable that has multiple return statements.
Usecase
Get a token:

if the token does not exist in the database then generate a new one and return it.
if the token exists  -check if expired, if expired update it with a new one,   -if not expired then return the same token.

Code
 export const GetToken = async () =&gt; {
    
        const db = new DB();
    
        const check = await db.GetItem();
    
        if(check.Count === 0) {
            const token = await GenerateToken();
            return token;
        }
    
        if(check.Count &gt;= 1) {
    
            const db_token = check.Items[0];
            const isExpired = isTokenExpired(db_token);
    
            if(isExpired) {
                const token = await UpdateToken(db_token);
                return token;
            }
            return db_token;
        }
    }

There are 3 return statements in this function and there is not a base return function.
I'm no expert in JavaScript, but it seems to me if you changed the scope of token so that it is defined at the beginning of the function and then just modify the value as necessary that you can have only one return statement after all the if statements.