Search code examples
javascriptsweetalertsweetalert2

How I can use result with another text with JavaScript


I am setting coupons things in my store but I want to do something with my JavaScript alter and I have no idea how to do it.

success: function (result) {
    Swal.fire({
        position: 'center',
        type: 'success',
        title: "Coupon check",
        text: (result),
        showConfirmButton: false,
        timer: 1500
    })
}

This is my script function with result and my question is how I can do like this:

Your coupon for (result) was successfully added!

As I do not know how I can use (result) in " or '.


Solution

  • Use string concatenation:

                text: "Your coupon for " + result + " was successfully added!",