From 07a071107df0773a41cd7ddaa727518de1df5c18 Mon Sep 17 00:00:00 2001 From: Eric Leung Date: Sun, 3 Jul 2016 15:26:08 -0700 Subject: [PATCH] Relax test regex checking other var initialization --- .../basic-javascript.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json index e96630c3c4..5c5a974495 100644 --- a/challenges/01-front-end-development-certification/basic-javascript.json +++ b/challenges/01-front-end-development-certification/basic-javascript.json @@ -5176,7 +5176,7 @@ "title": "Iterate Through an Array with a For Loop", "description": [ "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:", - "
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
console.log(arr[i]);
}
", + "
var arr = [10,9,8,7,6];
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
", "Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1.", "

Instructions

", "Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total." @@ -5205,10 +5205,10 @@ "var ourArr = [ 9, 10, 11, 12];\nvar ourTotal = 0;\n\nfor (var i = 0; i < ourArr.length; i++) {\n ourTotal += ourArr[i];\n}\n\nvar myArr = [ 2, 3, 4, 5, 6];\nvar total = 0;\n\nfor (var i = 0; i < myArr.length; i++) {\n total += myArr[i];\n}" ], "tests": [ - "assert(code.match(/var\\s*total\\s*=\\s*0\\s*;/), 'message: total should be declared and initialized to 0');", + "assert(code.match(/var.*?total\\s*=\\s*0.*?;/), 'message: total should be declared and initialized to 0');", "assert(total === 20, 'message: total should equal 20');", "assert(code.match(/for\\s*\\(/g).length > 1 && code.match(/myArr\\s*\\[/), 'message: You should use a for loop to iterate through myArr');", - "assert(!code.match(/total[\\s\\+\\-]*=\\s*(\\d(?!\\s*;)|[1-9])/g), 'message: Do not set total to 20 directly');" + "assert(!code.match(/total[\\s\\+\\-]*=\\s*(\\d(?!\\s*[;,])|[1-9])/g), 'message: Do not set total to 20 directly');" ], "type": "waypoint", "challengeType": 1,