fix(curriculum): ensure algorithm does not include the Array method `… (#38520)
* 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>
This commit is contained in:
@ -33,7 +33,7 @@ tests:
|
|||||||
- text: <code>mergeSort</code> should return an array that is unchanged except for order.
|
- text: <code>mergeSort</code> 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]);
|
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: <code>mergeSort</code> should not use the built-in <code>.sort()</code> method.
|
- text: <code>mergeSort</code> should not use the built-in <code>.sort()</code> 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]);
|
|||||||
<div id='js-teardown'>
|
<div id='js-teardown'>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
const removeJSComments = str => str.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
|
||||||
|
|
||||||
function isSorted(arr) {
|
function isSorted(arr) {
|
||||||
var check = (i) => (i == arr.length - 1) ? true : (arr[i] > arr[i + 1]) ? false : check(i + 1);
|
var check = (i) => (i == arr.length - 1) ? true : (arr[i] > arr[i + 1]) ? false : check(i + 1);
|
||||||
return check(0);
|
return check(0);
|
||||||
|
Reference in New Issue
Block a user