From dd2fb28ee069005c2d7229a9026ee0905c0988d6 Mon Sep 17 00:00:00 2001 From: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Date: Mon, 2 Dec 2019 15:42:32 -0800 Subject: [PATCH] fix: make tests more robust (#37830) --- .../iterate-through-an-array-with-a-for-loop.english.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 7dd26b6914b..7f8777d73e3 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 @@ -11,7 +11,7 @@ forumTopicId: 18216 A common task in JavaScript is to iterate through the contents of an array. One way to do that is with a for loop. This code will output each element of the array arr to the console: ```js -var arr = [10,9,8,7,6]; +var arr = [10, 9, 8, 7, 6]; for (var i = 0; i < arr.length; i++) { console.log(arr[i]); } @@ -36,8 +36,8 @@ tests: testString: assert(total === 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*\[/)); - - text: You should not set total to 20 directly. - testString: assert(!code.match(/total[\s\+\-]*=\s*(0(?!\s*[;,]?$)|[1-9])/gm)); + - text: You should not attempt to directly assign the value 20 to total. + testString: assert(!code.replace(/\s/g, '').match(/total[=+-]0*[1-9]+/gm)); ```