The Code

The Code

You need to use a Syntax Highlighter - Prism.js is default

document.getElementById("flipBtn").addEventListener('click', function () {
    let regex = /[\W_]/g;
    let userInput = document.getElementById("userInput").value;

    let lowerInput = userInput.toLowerCase().replace(regex, '');
    let reverseIn = lowerInput.split('').reverse().join('');


    if (reverseIn === lowerInput) {
        Swal.fire(
            "Palindrome!",
            "Nice! Try another!",
            'success'
        )
    }

    else {
        Swal.fire(
            "Not quite",
            "Try again!",
            'error'
        )
    }

    if (reverseIn == "") {
        Swal.fire(
            "Error",
            "Please enter a word or phrase"
        )
    }

    //Output new data

    document.getElementById("output").innerHTML = reverseIn;
})