vanilla javaScript :: return synchronous text file [duplicate]

I am trying to read and return pure text file with vanilla javaScript.

Now here is the issue.

This is working perfectly!

function getTxtFile(e)
{
    let t=new XMLHttpRequest;
    t.open('GET',e,!0),t.overrideMimeType('text/html'),t.onreadystatechange=function()
    {
        if(4===t.readyState&&(200===t.status||0===t.status))console.log(t.responseText)
    },t.send(null)
}

But when I change the console.log to return it does not returning anything.

function getTxtFile(e)
{
    let t=new XMLHttpRequest;
    t.open('GET',e,!0),t.overrideMimeType('text/html'),t.onreadystatechange=function()
    {
        if(4===t.readyState&&(200===t.status||0===t.status))return t.responseText
    },t.send(null)
}

One more thing to mentioned here is that it must by synchronous.