Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

no se porque cuando toco check me salta el alert de una y no corre el codigo, no se que tengo mal configurado, alguien me puede guiar??

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html>
<head>
  <meta charset = 'UTF-8'>
  <title>Palindrome Checker</title>
</head>
<body>
  
  <div class="container">
    <input id="text-input">
    <button id="check-btn">Check</button>
  </div>

  <div id="result"></div>

  <script src="script.js"></script>
</body>

</html>
/* file: styles.css */

/* file: script.js */
const textInput = document.getElementById('text-input').value;
const check = document.getElementById('check-btn');
const result = document.getElementById('result');

function isPalindrome(str) {
    let cleanStr = str.toLowerCase().replace(/[^A-Za-z0-9]/gi, '');
    let checkedStr = cleanStr.split('').reverse().join('');
    let resultMsg = `${str} ${cleanStr === checkedStr ? 'is' : 'is not'} a palindrome`
    return resultMsg;
}

const checkPalindrome = (str) => {
    if (textInput == "") {
        alert('ingrese una palabra o frase');
        return;
    }

    let cleanStr = str.toLowerCase().replace(/[^A-Za-z0-9]/gi, '');
    let checkedStr = cleanStr.split('').reverse().join('');
    let resultMsg = `${str} ${cleanStr === checkedStr ? 'is' : 'is not'} a palindrome`

    const pTag = document.createElement('p');
    pTag.className = 'user-input';
    pTag.innerHTML = resultMsg;
    result.appendChild(pTag);

    result.classList.remove('hidden');

} 

check.addEventListener('click', () => {
    checkPalindrome(textInput.value);
    textInput.value = "";
})



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

This is assigning the string that is in the #text-input input to textInput. So after this line, textInput contains a string.

If textInput is a string then it doesn’t have a value property. Look in the Console pane and you will see errors pointing this out.

Now it says that toLowerCase() is not a function. I dont understand what it means by that. The problem is here.

    let cleanStr = str.replace(/[^A-Za-z0-9]/gi, '').toLowerCase();

I try maybe changing replace with toLowerCase but its the same problem.

You’ll need to paste all of your code in here so we can see what the problem is. Just looking at one specific line of code isn’t enough to determine the problem.