diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf45ce0dc8d4270760c6d0.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf45ce0dc8d4270760c6d0.md index bfc11087a26..d48f573af17 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf45ce0dc8d4270760c6d0.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf45ce0dc8d4270760c6d0.md @@ -7,24 +7,26 @@ dashedName: step-22 # --description-- -Within your loop, you need to check if the character in `strArray` at index `i` is not a `+`, `-`, or a space. If it is not, `push` it to the `cleanStrArray`. - You will need to check if the array `["+", "-", " "]` does not include the current character. You can use a combination of the includes() method and the ! operator to do this. The `.includes()` method returns `true` if the array contains the character, and `false` if not. The logical NOT operator (`!`) will return the opposite of the value of the `.includes()` method. -Here is an example: +Here is an example checking if the current character is not in the vowels array. If it is not, that current character is pushed into the `consonantArray`: ```js -const numbersArray = [1, 2, 3, 4, 5] -const number = 6 +const inputString = "Hello World"; +const charArray = inputString.split(''); +const consonantArray = []; -if (!numbersArray.includes(number)) { - console.log("The number is not in the array.") +for (let i = 0; i < charArray.length; i++) { + if (!['a', 'e', 'i', 'o', 'u'].includes(charArray[i])) { + consonantArray.push(charArray[i]); + } } - ``` +Within your loop, you need to check if the character in `strArray` at index `i` is not a `+`, `-`, or a space. If it is not, `push` it to the `cleanStrArray`. + # --hints-- Your `for` loop should have an `if` statement. @@ -40,7 +42,7 @@ Your `for` loop should use `!["+", "-", " "].includes()`. assert.match(code, /for\s*\(\s*(let|var)\s+i\s*=\s*0\s*;\s*i\s*<\s*strArray\.length\s*;\s*i\s*\+\+\s*\)\s*\{\s*if\s*\(\s*!\s*\[\s*("|')\+\2\s*,\s*("|')-\3\s*,\s*("|')\s\4\s*\]\s*\.includes\(/); ``` -Your `for` loop should see if `strArray[i]` is found in `["+", "-", " "]`. +Your `for` loop should see if `!["+", "-", " "].includes(strArray[i])`. ```js assert.match(code, /for\s*\(\s*(let|var)\s+i\s*=\s*0\s*;\s*i\s*<\s*strArray\.length\s*;\s*i\s*\+\+\s*\)\s*\{\s*if\s*\(\s*!\s*\[\s*("|')\+\2\s*,\s*("|')-\3\s*,\s*("|')\s\4\s*\]\s*\.includes\(\s*strArray\s*\[\s*i\s*\]\s*\)\s*\)(\s*\{)?/);