Hello. I need help with step 22 of the calorie counter. I am having trouble understanding what a regular expression is. I also don’t know what I am supposed to do in this step because the wording is weird. Essentially, I do not know where to put the brackets, slashes, or the ±s thing.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
function cleanInputString(str) {
const regex = /[+-s]/;
}
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 OPR/109.0.0.0 (Edition std-1)
Challenge Information:
Learn Form Validation by Building a Calorie Counter - Step 22
Hello,
you need to add the \ before the s to make it work, regular expressions can be a difficult subject to understand at first, so I suggest you look for some YouTube videos explaining it like this one
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.