const input_text = document.querySelector("#input-text");
const output = document.querySelector("#output");
const btn_submit = document.querySelector("#btn-submit");

function is_palindrome(str)
{
    const str_length = str.length;
    let lower_str = str.toLowerCase();

    for (i = 0, j = str_length - 1; i < str_length && j >= 0; i++, j--)
    {
        if (lower_str[i] != lower_str[j])
        {
            return false;
        }
    }

    return true;
}

btn_submit.addEventListener("click", (event) => {
    const str = input_text.value;
    if (is_palindrome(str))
    {
        output.textContent = `String '${str}' is palindrome`;
    }
    else
    {
        output.textContent = `String '${str}' is NOT palindrome`;
    }
});
