Build a Palindrome Checker Project - Build a Palindrome Checker

Tell us what’s happening:

Hi everyone,

I’m a bit stuck in this project. I pass all the tests except “1 eye for of 1 eye.”, this one always fails and i’m not really sure why. I’ve gone through the code a few times but i can’t find what i’m missing.

Can you guide me to the right direction?

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang='eng'>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="styles.css" />
  <title>Palindrome Checker</title>
  <input id='text-input'  placeholder='Type word' />
  <button id='check-btn'>Check</button>
  <div id='result'>
    This will change
  <script src='./script.js'></script>
/* file: styles.css */
div {
  background-color: grey;
  color: black;
/* file: script.js */
const input = document.getElementById('text-input');
const button = document.getElementById('check-btn');
const result = document.getElementById('result');

const checkPalindrome = () => {

const valueWord = input.value;

const regEx = /[^A-Za-z0–9]/gi;

const newWord = valueWord
.replace(regEx,  '')

const reverseWord =

if(input.value === ''){
    return alert('Please input a value');

const resultWord = newWord === reverseWord  ?  `<p>${input.value} is a palindrome</p>`  :  `<p>${input.value} is not a palindrome</p>`;

result.innerHTML= resultWord;

button.addEventListener('click',  checkPalindrome)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36 Edg/

Challenge Information:

Build a Palindrome Checker Project - Build a Palindrome Checker

Not sure if you copied the regex from somewhere or wrote it but it looks like the last dash - is not correct.


Replace that last one.

Just to be super clear. I’m talking about the dashes in your regex. The last one between the numbers is not the right type of dash.

This will fail

const regEx = /[^A-Za-z0–9]/gi;

This will pass

const regEx = /[^A-Za-z0-9]/gi;
1 Like

Thank you so much for your input.

Indeed i had copied the regex after i quickly googled for regex non alphanumeric,but i never saw that it was a different type of dash. Now all the tests pass.

Again,thank you for your help,it is greatly appreciated :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.