I declared a variable named check = false and I want re-assign it equal true but when it ran through the "if" condition, it was still equal false
If you know how to fix it, please help me. Thank you very much!
function deletePost(event) {
  // Get a reference to the button element
  var check = false;
  Swal.fire({
    title: "Are you sure to reject this candidate?",
    icon: "warning",
    showCancelButton: true,
    confirmButtonColor: "#3085d6",
    cancelButtonColor: "#d33",
    confirmButtonText: "Yes, i'am sure",
    customClass: {
      title: "my-title",
      content: "my-content",
      confirmButton: "my-confirm-button",
      cancelButton: "my-cancel-button",
    },
  }).then((result) => {
    if (result.isConfirmed) {
      Swal.fire(
        "Rejected Successfully!",
        "The Candidate will be informed.",
        "success"
      );
      check = true;
    }
  });
  console.log(check);
  event.preventDefault();
  if (check) {
    window.location.href = event.currentTarget.getAttribute("href");
    console.log(check);
  } else {
  }
}
I tried to re-assign the value of check equal true but I didn't work
 
    