Learn Form Validation by Building a Calorie Counter - Step 23

For this step i have added the g flag to my regex value but it keeps on saying you should add the g flag to your regex value. I have reset it but it is still not working pls may i get help as i am confused why it says you should add the g flag to your regex value when I have.

Your code so far

/* file: script.js */

function cleanInputString(str) {
  const regex = /[-\s]+/g;
  return str.replace(regex, '');
}
let input = "This - is a test - string";
let cleaned = cleanInputString(input);
console.log(cleaned); 

Your browser information:

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

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 23

if the step is only adding the g flag, why have you added these lines?


you have also made changes to this line over just adding the g flag

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