javascript function return undefined while the variable is set [duplicate]

i have no idea why this code return undefined
i set success variable so if request is success its true otherwise its false

function deleteorder(url, pk) {
    let success
    $.ajax
        (
            {
                type: "GET",
                url: url,

                success: function (data) {
                    console.log("object deleted")
                    success = true
                },
                error: function (data) {
                    console.log(data)
                    success = false
                }
            }
        )
    return success
}

but when i run the function below its log undefined on console

function deletefromcart(url,pk){
    let status;
    status = deleteorder(url,pk)
    console.log(status)
    if(status==true){
        $("#cart"+pk).remove()
        $("#row"+pk).remove()
        if($("tbody > tr").length==0){
            setTimeout(() => {
                location.reload()
            }, 500);
            
        }
    }

}

browser image

so any idea why this happened?