diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.english.md index 049734e3e7..7e73a4e568 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop.english.md @@ -22,13 +22,13 @@ Declare and initialize a variable total to 0. Use a total should be declared and initialized to 0 - testString: assert(code.match(/var.*?total\s*=\s*0.*?;/), 'total should be declared and initialized to 0'); + testString: assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/), 'total should be declared and initialized to 0'); - text: total should equal 20 testString: assert(total === 20, 'total should equal 20'); - text: You should use a for loop to iterate through myArr testString: assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), 'You should use a for loop to iterate through myArr'); - text: Do not set total to 20 directly - testString: assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), 'Do not set total to 20 directly'); + testString: assert(!code.match(/total[\s\+\-]*=\s*(0(?!\s*[;,]?$)|[1-9])/gm), 'Do not set total to 20 directly'); ``` @@ -64,6 +64,7 @@ var myArr = [ 2, 3, 4, 5, 6]; ```js (function(){if(typeof total !== 'undefined') { return "total = " + total; } else { return "total is undefined";}})() + ```