From 46e0748af36d64f8a7c5c2b759e3018f6c572d31 Mon Sep 17 00:00:00 2001 From: Ashraf Nazar Date: Mon, 27 Apr 2020 13:28:37 +0100 Subject: [PATCH] =?UTF-8?q?fix(curriculum):=20ensure=20algorithm=20does=20?= =?UTF-8?q?not=20include=20the=20Array=20method=20`=E2=80=A6=20(#38520)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(curriculum): replace comments with empty strings in merge-sort challenge * Update curriculum/challenges/english/08-coding-interview-prep/algorithms/implement-merge-sort.english.md Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> --- .../algorithms/implement-merge-sort.english.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/08-coding-interview-prep/algorithms/implement-merge-sort.english.md b/curriculum/challenges/english/08-coding-interview-prep/algorithms/implement-merge-sort.english.md index df2bda05c5..cd4c4fb4ee 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/algorithms/implement-merge-sort.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/algorithms/implement-merge-sort.english.md @@ -33,7 +33,7 @@ tests: - text: mergeSort should return an array that is unchanged except for order. testString: assert.sameMembers(mergeSort([1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]), [1,4,2,8,345,123,43,32,5643,63,123,43,2,55,1,234,92]); - text: mergeSort should not use the built-in .sort() method. - testString: assert(!code.match(/\.?[\s\S]*?sort/)); + testString: assert(!removeJSComments(code).match(/\.?[\s\S]*?sort\s*\(/)); ``` @@ -62,6 +62,8 @@ mergeSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);
```js +const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, ''); + function isSorted(arr) { var check = (i) => (i == arr.length - 1) ? true : (arr[i] > arr[i + 1]) ? false : check(i + 1); return check(0);