fix(curriculum): consistent space checking around semicolon (#53722)

This commit is contained in:
Krzysztof G
2024-02-24 20:56:46 +01:00
committed by GitHub
parent 511e6c8c29
commit 341b3f9e08
281 changed files with 604 additions and 606 deletions
@@ -22,7 +22,7 @@ Set the initial value of the accumulator to `0`.
Your `reduce` method should have `0` as the initial value.
```js
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)/)
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)/)
```
# --seed--
@@ -28,13 +28,13 @@ assert.notMatch(getMean.toString(), /mean\s*=/);
You should not change the logic within the `reduce` method.
```js
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)/)
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)/)
```
You should divide the result of the `reduce` method by the length of the array.
```js
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)\s*\/\s*array\.length/)
assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)\s*\/\s*array\.length/)
```
You should use implicit return syntax to directly return the result of `reduce` divided by the array length.
@@ -20,7 +20,7 @@ assert.match(calculate.toString(), /mean\s*=/);
Your `mean` variable should be assigned the value of `getMean(numbers)`.
```js
assert.match(calculate.toString(), /mean\s*=\s*getMean\(\s*numbers\s*\);/);
assert.match(calculate.toString(), /mean\s*=\s*getMean\(\s*numbers\s*\)\s*;?/);
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\
Your `calculate` function should set the `#mean` element's `.textContent` to the value of `mean`.
```js
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\)\s*\.textContent\s*=\s*mean;/);
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\)\s*\.textContent\s*=\s*mean\s*;?/);
```
# --seed--
@@ -16,7 +16,7 @@ To resolve this, add `return false;` after your `calculate();` call in the `onsu
Your `onsubmit` attribute should have a `return false;` statement.
```js
assert.match(document.querySelector("form").getAttribute("onsubmit"), /return\s+false;/);
assert.match(document.querySelector("form").getAttribute("onsubmit"), /return\s+false\s*;?/);
```
Your `onsubmit` attribute should still call `calculate()`.
@@ -28,7 +28,7 @@ assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate
You should return `false` after you call `calculate()`.
```js
assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate\(\s*\);\s*return\s+false;/);
assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate\(\s*\)\s*;?\s*return\s+false\s*;?/);
```
# --seed--
@@ -22,7 +22,7 @@ assert.match(getMedian.toString(), /sorted\s*=/);
Your `getMedian` function should assign `array.sort()` to the `sorted` variable.
```js
assert.match(getMedian.toString(), /sorted\s*=\s*array\.sort\(\s*\);/);
assert.match(getMedian.toString(), /sorted\s*=\s*array\.sort\(\s*\)\s*;?/);
```
# --seed--
@@ -16,7 +16,7 @@ Like the `getMean` function, you could condense this code into one line and redu
Your `getMedian` function should return the value of `median`.
```js
assert.match(getMedian.toString(), /return\s+median;/);
assert.match(getMedian.toString(), /return\s+median\s*;?/);
```
# --seed--
@@ -20,7 +20,7 @@ assert.match(getMode.toString(), /counts\s*=/);
Your `counts` variable should be an empty object.
```js
assert.match(getMode.toString(), /counts\s*=\s*\{\s*\};/);
assert.match(getMode.toString(), /counts\s*=\s*\{\s*\}\s*;?/);
```
# --seed--
@@ -36,7 +36,7 @@ assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\(
Your `if` statement should return `null` if the `size` property of the new `Set` is equal to `1`.
```js
assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\(\s*counts\s*\)\s*\)\.size\s*===\s*1\s*\)\s*\{?\s*return\s+null;\s*\}?/);
assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\(\s*counts\s*\)\s*\)\.size\s*===\s*1\s*\)\s*\{?\s*return\s+null\s*;?\s*\}?/);
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(getMode.toString(), /return\s+mode\.join\(/)
You should separate the elements of the `mode` array with a comma and a space.
```js
assert.match(getMode.toString(), /return\s+mode\.join\(\s*('|"),\s\1\s*\);/)
assert.match(getMode.toString(), /return\s+mode\.join\(\s*('|"),\s\1\s*\)\s*;?/)
```
# --seed--
@@ -14,13 +14,13 @@ Add your `getMode()` function to your `calculate` logic, and update the respecti
Your `calculate` function should have a `mode` variable with the value of `getMode(numbers)`.
```js
assert.match(calculate.toString(), /mode\s*=\s*getMode\(\s*numbers\s*\);/);
assert.match(calculate.toString(), /mode\s*=\s*getMode\(\s*numbers\s*\)\s*;?/);
```
Your `calculate` function should query the DOM for the `#mode` element and set the `textContent` to `mode`.
```js
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mode\1\s*\)\.textContent\s*=\s*mode;/);
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mode\1\s*\)\.textContent\s*=\s*mode\s*;?/);
```
# --seed--
@@ -14,13 +14,13 @@ Add the logic for calculating and displaying the range to your `calculate` funct
Your `calculate` function should set a `range` variable to the result of `getRange(numbers)`.
```js
assert.match(calculate.toString(), /range\s*=\s*getRange\(\s*numbers\s*\);/);
assert.match(calculate.toString(), /range\s*=\s*getRange\(\s*numbers\s*\)\s*;?/);
```
Your `calculate` function should set the `#range` element's `textContent` to the `range` variable.
```js
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#range\1\s*\)\.textContent\s*=\s*range;/);
assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#range\1\s*\)\.textContent\s*=\s*range\s*;?/);
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(getVariance.toString(), /mean\s*=/);
Your `mean` variable should be assigned the value of the `getMean` function, passing the `array` argument.
```js
assert.match(getVariance.toString(), /mean\s*=\s*getMean\(\s*array\s*\);/);
assert.match(getVariance.toString(), /mean\s*=\s*getMean\(\s*array\s*\)\s*;?/);
```
# --seed--
@@ -32,7 +32,7 @@ assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\
Your `map` callback should return the value of `el` minus `mean`.
```js
assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+el\s*-\s*mean;?\s*\}/);
assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+el\s*-\s*mean\s*;?\s*\}/);
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\
Your `map` callback should return the value of `el` squared.
```js
assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+Math\.pow\(\s*el\s*,\s*2\s*\);\s*\}/);
assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+Math\.pow\(\s*el\s*,\s*2\s*\)\s*;?\s*\}/);
```
Your `map` callback should use the `**` operator.
@@ -34,7 +34,7 @@ assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDiffere
Your `reduce` callback should return the sum of `acc` and `el`.
```js
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*return\s*acc\s*\+\s*el\s*\;\s*\}\s*,\s*0\s*\)/);
assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*return\s*acc\s*\+\s*el\s*;\s*\}\s*,\s*0\s*\)/);
```
# --seed--
@@ -32,19 +32,19 @@ assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\
Your `squared` variable should be set to the value of `difference` to the power of 2.
```js
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);/);
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?/);
```
Your `reduce` callback should return the value of `acc` plus `squared`.
```js
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;/);
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;/);
```
You should not remove the initial value of `0` from your `.reduce()` method.
```js
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)/);
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)/);
```
# --seed--
@@ -16,7 +16,7 @@ Divide your `.reduce()` call by the length of the array (in your `variance` decl
You should divide the result of the `.reduce()` call by the length of the array.
```js
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)\s*\/\s*array\.length;/);
assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)\s*\/\s*array\.length\s*;?/);
```
You should return the value of `variance`.
@@ -16,7 +16,7 @@ Change your `standardDeviation` variable to use this method instead of `Math.pow
Your `standardDeviation` variable should use `Math.sqrt()`.
```js
assert.match(getStandardDeviation.toString(), /standardDeviation\s*=\s*Math\.sqrt\(\s*variance\s*\);/);
assert.match(getStandardDeviation.toString(), /standardDeviation\s*=\s*Math\.sqrt\(\s*variance\s*\)\s*;?/);
```
# --seed--
@@ -14,7 +14,7 @@ Return your `standardDeviation` variable.
Your `getStandardDeviation` function should return the `standardDeviation` variable.
```js
assert.match(getStandardDeviation.toString(), /return\s+standardDeviation;/);
assert.match(getStandardDeviation.toString(), /return\s+standardDeviation\s*;?/);
```
# --seed--
@@ -22,7 +22,7 @@ assert.match(code, /const\s+data/);
You should assign `await res.json()` to the `data` variable.
```js
assert.match(code, /\s*const\s+data\s*=\s*await\s+res\.json\(\s*\);?\s*/);
assert.match(code, /\s*const\s+data\s*=\s*await\s+res\.json\(\s*\)\s*;?\s*/);
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(code, /\s*try\s*{[\s\S]*\s*console\.log\(\s*data\s*\)[\s\S]*}\s*cat
You should call the `fetchData()` function, after the `fetchData()` function is defined.
```js
assert.match(code, /};?\s*fetchData\(\s*\)/);
assert.match(code, /}\s*;?\s*fetchData\(\s*\)/);
```
# --seed--
@@ -16,13 +16,13 @@ Call the `showLatestPosts()` function at the end of your `try` block and pass in
You should call `showLatestPosts()` at the end of your `try` block.
```js
assert.match(code, /\s*showLatestPosts\(.*\);??\s*/);
assert.match(code, /\s*showLatestPosts\(.*\)\s*;?\s*/);
```
You should pass `data` as the argument to `showLatestsPosts()`.
```js
assert.match(code, /\s*showLatestPosts\(\s*data\s*\);?\s*/);
assert.match(code, /\s*showLatestPosts\(\s*data\s*\)\s*;?\s*/);
```
# --seed--
@@ -16,7 +16,7 @@ Destructure the `topics` array from the `topic_list` object.
You should use `const` to destructure the `topics` variable from the `topic_list` object.
```js
assert(code.match(/\s*const\s*\{\s*topics\s*\}\s*=\s*topic_list;?\s*/g));
assert(code.match(/\s*const\s*\{\s*topics\s*\}\s*=\s*topic_list\s*;?\s*/g));
```
# --seed--
@@ -20,7 +20,7 @@ assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*cons
You should use `innerText` to set the text of `outputValueNode` to `num`.
```js
assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*const\s+outputValueNode\s*=\s*document\.getElementById\s*\(\s*`output-value-\$\{i\}`\s*\)\s*;?\s*outputValueNode\.innerText\s*=\s*num;?/)
assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*const\s+outputValueNode\s*=\s*document\.getElementById\s*\(\s*`output-value-\$\{i\}`\s*\)\s*;?\s*outputValueNode\.innerText\s*=\s*num\s*;?/)
```
# --seed--
@@ -16,25 +16,25 @@ Create an `if` condition that checks if the current element is larger than the n
You should not remove your `console.log` statement.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?/);
```
You should use an `if` statement in your nested loop.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(/);
```
Your `if` statement should check if the `array[j]` is larger than the `array[j+1]`.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)/);
```
Your `if` statement should be empty.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*}/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*}/);
```
# --seed--
@@ -16,25 +16,25 @@ To do this, declare a `temp` variable and assign it the value of `array[j]`. The
Within your `if` statement, you should declare a `temp` variable.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=/);
```
You should assign `temp` the value of `array[j]`.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?/);
```
You should assign `array[j]` the value of `array[j + 1]`.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?/);
```
You should assign `array[j + 1]` the value of `temp`.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?/);
```
# --seed--
@@ -14,7 +14,7 @@ Finally, after your outer loop has finished executing, return the sorted array.
You should `return` the `array` variable.
```js
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?\s*}\s*}\s*}\s*return\s+array;?\s*}/);
assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?\s*}\s*}\s*}\s*return\s+array\s*;?\s*}/);
```
# --seed--
@@ -34,25 +34,25 @@ assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{
You should pass `array[minIndex]` as the third argument to `console.log()`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?/);
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?/);
```
You should have an `if` statement after your `console.log()` call.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(?/);
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(?/);
```
You should have a condition in your `if` statement that checks if `array[j]` is less than `array[minIndex]`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{?/);
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{?/);
```
Your `if` statement should set `minIndex` to `j`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}/);
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}/);
```
# --seed--
@@ -16,25 +16,25 @@ Like you did in your bubble sort, use a `temp` variable to extract the value at
After your nested `for` loop, you should declare a `temp` variable.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=/);
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=/);
```
You should assign `array[i]` to `temp`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]/)
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]/)
```
You should assign `array[minIndex]` to `array[i]`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]/)
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]/)
```
You should assign `temp` to `array[minIndex]`.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}/)
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}/)
```
# --seed--
@@ -14,7 +14,7 @@ Finally, after your outer loop has finished, you need to return the array. Once
You should `return` the `array` after your outer loop completes.
```js
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}\s*return\s+array;?\s*/)
assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}\s*return\s+array\s*;?\s*/)
```
# --seed--
@@ -43,7 +43,7 @@ assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{
Your `while` loop should decrement `j` inside the loop.
```js
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*j--;?\s*\}/);
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*j--\s*;?\s*\}/);
```
# --seed--
@@ -16,7 +16,7 @@ Do so by assigning the value at the `j` index to the next index.
Before decrementing `j`, assign the value at `j` to the index `j + 1`.
```js
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}/);
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}/);
```
# --seed--
@@ -16,7 +16,7 @@ Use the assignment operator to insert your current value into the correct index.
You should assign `currValue` to the index `j + 1`.
```js
assert.match(code, /const\s+insertionSort\s*=\s*\(\s*array\s*\)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue;?/);
assert.match(code, /const\s+insertionSort\s*=\s*\(\s*array\s*\)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue\s*;?/);
```
# --seed--
@@ -14,7 +14,7 @@ After your `for` loop has finished, you need to return the array. You should the
You should `return` the `array`.
```js
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue;?\s*\}\s*return\s+array;?\s*\}/);
assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue\s*;?\s*\}\s*return\s+array\s*;?\s*\}/);
```
# --seed--
@@ -26,7 +26,7 @@ assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(
Your callback function should return `a - b`.
```js
assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*return\s+a\s*-\s*b;?\s*}\s*\)/);
assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*return\s+a\s*-\s*b\s*;?\s*}\s*\)/);
```
# --seed--
@@ -26,7 +26,7 @@ assert.isUndefined(fighting);
You should not assign a value to your `fighting` variable. Don't forget the semi-colon at the end of the line.
```js
assert.match(code, /let\s+fighting;/);
assert.match(code, /let\s+fighting\s*;/);
```
# --seed--
@@ -32,7 +32,7 @@ assert.isUndefined(monsterHealth);
You should not assign a value to your `monsterHealth` variable. Remember your semi-colon.
```js
assert.match(code, /let\s+monsterHealth;/);
assert.match(code, /let\s+monsterHealth\s*;/);
```
You should use `let` to declare your `inventory` variable.
@@ -50,7 +50,7 @@ assert.isUndefined(inventory);
You should not assign a value to your `inventory` variable. Remember your semi-colon.
```js
assert.match(code, /let\s+inventory;/);
assert.match(code, /let\s+inventory\s*;/);
```
# --seed--
@@ -20,13 +20,13 @@ function functionName() {
You should have a `console.log("Going to store.");` line in your code. Don't forget the semi-colon.
```js
assert.match(code, /console\.log\(\s*('|")Going to store\.\1\s*\);/);
assert.match(code, /console\.log\(\s*('|")Going to store\.\1\s*\)\s*;/);
```
Your `console.log("Going to store.");` line should be in your `goStore` function.
```js
assert.match(goStore.toString(), /console\.log\(\s*('|")Going to store\.\1\s*\);/);
assert.match(goStore.toString(), /console\.log\(\s*('|")Going to store\.\1\s*\)\s*;/);
```
# --seed--
@@ -26,7 +26,7 @@ assert.match(goTown.toString(), /update\(\s*\)/);
Don't forget your ending semi-colon.
```js
assert.match(goTown.toString(), /update\(\s*\);/);
assert.match(goTown.toString(), /update\(\s*\)\s*;/);
```
# --seed--
@@ -20,7 +20,7 @@ Pass your `locations` array into the `update` call.
You should pass the `locations` array into the `update` call.
```js
assert.match(goTown.toString(), /update\(\s*locations\s*\);/);
assert.match(goTown.toString(), /update\(\s*locations\s*\)\s*;?/);
```
# --seed--
@@ -30,13 +30,13 @@ assert.match(code, /locations\s*\[\s*0\s*\]/);
You should pass the first object in the `locations` array into the `update` function.
```js
assert.match(code, /update\(\s*locations\s*\[\s*0\s*\]\s*\);/);
assert.match(code, /update\(\s*locations\s*\[\s*0\s*\]\s*\)\s*;?/);
```
This call should still be in your `goTown()` function.
```js
assert.match(goTown.toString(), /update\(\s*locations\s*\[\s*0\s*\]\s*\);/);
assert.match(goTown.toString(), /update\(\s*locations\s*\[\s*0\s*\]\s*\)\s*;?/);
```
# --seed--
@@ -39,7 +39,7 @@ assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)/);
All of your `buyHealth` code should be inside the `if` statement.
```js
assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)\s*{\s*gold\s*-=\s*10;\s*health\s*\+=\s*10;\s*goldText\.innerText\s*=\s*gold;\s*healthText\.innerText\s*=\s*health;\s*}/);
assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)\s*{\s*gold\s*-=\s*10\s*;?\s*health\s*\+=\s*10\s*;?\s*goldText\.innerText\s*=\s*gold\s*;?\s*healthText\.innerText\s*=\s*health\s*;?\s*}/);
```
# --seed--
@@ -26,7 +26,7 @@ assert.match(code, /let\s+newWeapon/);
`newWeapon` should be initialised to have the value of `weapons`. Don't forget your semi-colon.
```js
assert.match(buyWeapon.toString(), /newWeapon\s*=\s*weapons;/);
assert.match(buyWeapon.toString(), /newWeapon\s*=\s*weapons\s*;/);
```
`newWeapon` should be declared before you modify `text`.
@@ -22,7 +22,7 @@ assert.match(buyWeapon.toString(), /button2\.innerText/);
You should set the value of `button2.innerText` to `"Sell weapon for 15 gold"`.
```js
assert.match(buyWeapon.toString(), /button2\.innerText\s*=\s*('|")Sell weapon for 15 gold\1;/);
assert.match(buyWeapon.toString(), /button2\.innerText\s*=\s*('|")Sell weapon for 15 gold\1\s*;?/);
```
You should set the value of `button2.onclick`.
@@ -34,7 +34,7 @@ assert.match(buyWeapon.toString(), /button2\.onclick/);
You should set the value of `button2.onclick` to `sellWeapon`.
```js
assert.match(buyWeapon.toString(), /button2\.onclick\s*=\s*sellWeapon;/);
assert.match(buyWeapon.toString(), /button2\.onclick\s*=\s*sellWeapon\s*;?/);
```
# --seed--
@@ -16,7 +16,7 @@ On the next line, call the `goFight` function.
You should set `fighting` equal to `0`.
```js
assert.match(fightSlime.toString(), /fighting\s*=\s*0;/);
assert.match(fightSlime.toString(), /fighting\s*=\s*0\s*;?/);
```
You should not use `let` or `const`.
@@ -28,7 +28,7 @@ assert.notMatch(fightSlime.toString(), /let|const/);
You should call the `goFight` function.
```js
assert.match(fightSlime.toString(), /goFight\(\s*\);/);
assert.match(fightSlime.toString(), /goFight\(\s*\)\s*;?/);
```
# --seed--
@@ -14,13 +14,13 @@ Following the same pattern as the `fightSlime` function, use that code in the `f
You should set `fighting` to `1` in your `fightBeast` function.
```js
assert.match(fightBeast.toString(), /fighting\s*=\s*1;/);
assert.match(fightBeast.toString(), /fighting\s*=\s*1\s*;?/);
```
You should set `fighting` to `2` in your `fightDragon` function.
```js
assert.match(fightDragon.toString(), /fighting\s*=\s*2;/);
assert.match(fightDragon.toString(), /fighting\s*=\s*2\s*;?/);
```
You should remove the `console.log` from your `fightDragon` function.
@@ -14,13 +14,13 @@ Add an `else` statement to the first `if` statement inside your `attack()` funct
You should add an `else` block after your `if (isMonsterHit())` block.
```js
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else/)
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1\s*;?\s*\}\s*else/)
```
You should add the text `" You miss."` to the end of `text.innerText`. Remember to use compound assignment and make sure there is a space before the word `You`.
```js
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else\s*\{\s*text\.innerText\s*\+=\s*('|")\sYou miss\.\1/)
assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1\s*;?\s*\}\s*else\s*\{\s*text\.innerText\s*\+=\s*('|")\sYou miss\.\1/)
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(attack.toString(), /--/);
You should decrement `currentWeapon` in your `if` statement.
```js
assert.match(attack.toString(), /(currentWeapon\s*--;?\s*}\s*})$/);
assert.match(attack.toString(), /(currentWeapon\s*--\s*;?\s*}\s*})$/);
```
# --seed--
@@ -29,7 +29,7 @@ You should use destructuring to get the `name` and `price` variables from `produ
```js
const afterAdd = code.split("addItem")[1];
assert.match(afterAdd, /const\s*\{\s*name\s*,\s*price\s*\}\s*=\s*product;?\b/);
assert.match(afterAdd, /const\s*\{\s*name\s*,\s*price\s*\}\s*=\s*product\s*;?\b/);
```
# --seed--
@@ -18,13 +18,13 @@ Use `const` to create a variable named `audio` and set it equal to `new Audio()`
You should use the `new` keyword to create an instance of the `Audio` object.
```js
assert.match(code, /new\s+Audio\(\s*\);?/)
assert.match(code, /new\s+Audio\(\s*\)\s*;?/)
```
You should assign the `Audio` object to a constant named `audio`.
```js
assert.match(code, /const\s+audio\s*=\s*new\s+Audio\(\s*\);?/)
assert.match(code, /const\s+audio\s*=\s*new\s+Audio\(\s*\)\s*;?/)
```
# --seed--
@@ -40,7 +40,7 @@ assert.match(code, /const\s+playSong\s*=\s*\(?\s*id/)
Your `playSong` function should be empty.
```js
assert.match(code, /const\s+playSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+playSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -40,13 +40,13 @@ assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)/)
Your `find` method should use strict equality to check if `song.id` is equal to `id`.
```js
assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\);?/)
assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\)\s*;?/)
```
Your `find` method should be assigned to a `song` constant.
```js
assert.match(code, /const\s+song\s*=\s*userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\);?/)
assert.match(code, /const\s+song\s*=\s*userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\)\s*;?/)
```
# --seed--
@@ -16,19 +16,19 @@ Also, set the `audio.title` property equal to `song.title`. This tells the audio
You should not modify the existing `playSong` function and its content.
```js
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*===\s*id\s*\);?/)
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*===\s*id\s*\)\s*;?/)
```
You should set `audio.src` to `song.src`.
```js
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s*===\s*id\s*\);?\s*audio\.src\s*=\s*song\.src;?/)
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s*===\s*id\s*\)\s*;?\s*audio\.src\s*=\s*song\.src\s*;?/)
```
You should set `audio.title` to `song.title`.
```js
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s===\s*id\s*\);?\s*audio\.src\s*=\s*song\.src;?\s*audio\.title\s*=\s*song\.title;?\s*\};?/)
assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s===\s*id\s*\)\s*;?\s*audio\.src\s*=\s*song\.src\s*;?\s*audio\.title\s*=\s*song\.title\s*;?\s*\}\s*;?/)
```
# --seed--
@@ -23,7 +23,7 @@ assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*user
You should set `audio.currentTime` to `0` inside your `if` block.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0;?\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}/)
```
# --seed--
@@ -18,7 +18,7 @@ Start by accessing the `userData` object and its `currentSong` property. Set its
You should assign `song` to `userData.currentSong`.
```js
assert.match(code, /userData\.currentSong\s*=\s*song;?/)
assert.match(code, /userData\.currentSong\s*=\s*song\s*;?/)
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1/)
You should use arrow syntax to pass in an empty callback into your event listener. Don't forget you also need an empty pair of curly braces.
```js
assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\);?/)
assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/)
```
# --seed--
@@ -56,7 +56,7 @@ assert.match(code, /const\s+renderSongs\s*=\s*\(?\s*array/)
Your `renderSongs` function should be empty.
```js
assert.match(code, /const\s+renderSongs\s*=\s*\(?\s*array\s*\)?\s*=>\s*\{\s*\};?/)
assert.match(code, /const\s+renderSongs\s*=\s*\(?\s*array\s*\)?\s*=>\s*\{\s*\}\s*;?/)
```
# --seed--
@@ -28,13 +28,13 @@ assert.match(code, /return\s*`\s*<li\s*/)
Your opening `li` tag should have an `id` attribute set to `song-${song.id}`.
```js
assert.match(code, /return\s*`\s*<li[^>]*\sid\s*=\s*('|")song-\$\{song\.id\}\1[^>]*>\s*<\/li>\s*`;?/)
assert.match(code, /return\s*`\s*<li[^>]*\sid\s*=\s*('|")song-\$\{song\.id\}\1[^>]*>\s*<\/li>\s*`\s*;?/)
```
Your opening `li` tag should have a `class` attribute set to `playlist-song`.
```js
assert.match(code, /return\s*`\s*<li[^>]*\sclass\s*=\s*('|")playlist-song\1[^>]*>\s*<\/li>\s*`;?/)
assert.match(code, /return\s*`\s*<li[^>]*\sclass\s*=\s*('|")playlist-song\1[^>]*>\s*<\/li>\s*`\s*;?/)
```
# --seed--
@@ -30,7 +30,7 @@ array.map().join();
You should add `join("")` to the existing code.
```js
assert.match(code, /<button\s+class\s*=\s*('|")playlist-song-delete\1\s*aria-label\s*=\s*('|")Delete\s*\$\{song\.title\}\2>\s*<svg\s{1}width="20"\s{1}height="20"\s{1}viewBox="0\s{1}0\s{1}16\s{1}16"\s{1}fill="none"\s{1}xmlns="http:\/\/www\.w3\.org\/2000\/svg">\s*<circle\s{1}cx="8"\s{1}cy="8"\s{1}r="8"\s{1}fill="#4d4d62"\/>\s*<path\s{1}fill-rule="evenodd"\s{1}clip-rule="evenodd"\s{1}d="M5\.32587\s{1}5\.18571C5\.7107\s{1}4\.90301\s{1}6\.28333\s{1}4\.94814\s{1}6\.60485\s{1}5\.28651L8\s{1}6\.75478L9\.39515\s{1}5\.28651C9\.71667\s{1}4\.94814\s{1}10\.2893\s{1}4\.90301\s{1}10\.6741\s{1}5\.18571C11\.059\s{1}5\.4684\s{1}11\.1103\s{1}5\.97188\s{1}10\.7888\s{1}6\.31026L9\.1832\s{1}7\.99999L10\.7888\s{1}9\.68974C11\.1103\s{1}10\.0281\s{1}11\.059\s{1}10\.5316\s{1}10\.6741\s{1}10\.8143C10\.2893\s{1}11\.097\s{1}9\.71667\s{1}11\.0519\s{1}9\.39515\s{1}10\.7135L8\s{1}9\.24521L6\.60485\s{1}10\.7135C6\.28333\s{1}11\.0519\s{1}5\.7107\s{1}11\.097\s{1}5\.32587\s{1}10\.8143C4\.94102\s{1}10\.5316\s{1}4\.88969\s{1}10\.0281\s{1}5\.21121\s{1}9\.68974L6\.8168\s{1}7\.99999L5\.21122\s{1}6\.31026C4\.8897\s{1}5\.97188\s{1}4\.94102\s{1}5\.4684\s{1}5\.32587\s{1}5\.18571Z"\s{1}fill="white"\/>\s*<\/svg>\s*<\/button>\s*<\/li>\s*`;?\s*\}\s*\)\s*\.join\(\s*('|")\3\s*\);?/)
assert.match(code, /<button\s+class\s*=\s*('|")playlist-song-delete\1\s*aria-label\s*=\s*('|")Delete\s*\$\{song\.title\}\2>\s*<svg\s{1}width="20"\s{1}height="20"\s{1}viewBox="0\s{1}0\s{1}16\s{1}16"\s{1}fill="none"\s{1}xmlns="http:\/\/www\.w3\.org\/2000\/svg">\s*<circle\s{1}cx="8"\s{1}cy="8"\s{1}r="8"\s{1}fill="#4d4d62"\/>\s*<path\s{1}fill-rule="evenodd"\s{1}clip-rule="evenodd"\s{1}d="M5\.32587\s{1}5\.18571C5\.7107\s{1}4\.90301\s{1}6\.28333\s{1}4\.94814\s{1}6\.60485\s{1}5\.28651L8\s{1}6\.75478L9\.39515\s{1}5\.28651C9\.71667\s{1}4\.94814\s{1}10\.2893\s{1}4\.90301\s{1}10\.6741\s{1}5\.18571C11\.059\s{1}5\.4684\s{1}11\.1103\s{1}5\.97188\s{1}10\.7888\s{1}6\.31026L9\.1832\s{1}7\.99999L10\.7888\s{1}9\.68974C11\.1103\s{1}10\.0281\s{1}11\.059\s{1}10\.5316\s{1}10\.6741\s{1}10\.8143C10\.2893\s{1}11\.097\s{1}9\.71667\s{1}11\.0519\s{1}9\.39515\s{1}10\.7135L8\s{1}9\.24521L6\.60485\s{1}10\.7135C6\.28333\s{1}11\.0519\s{1}5\.7107\s{1}11\.097\s{1}5\.32587\s{1}10\.8143C4\.94102\s{1}10\.5316\s{1}4\.88969\s{1}10\.0281\s{1}5\.21121\s{1}9\.68974L6\.8168\s{1}7\.99999L5\.21122\s{1}6\.31026C4\.8897\s{1}5\.97188\s{1}4\.94102\s{1}5\.4684\s{1}5\.32587\s{1}5\.18571Z"\s{1}fill="white"\/>\s*<\/svg>\s*<\/button>\s*<\/li>\s*`\s*;?\s*\}\s*\)\s*\.join\(\s*('|")\3\s*\)\s*;?/)
```
# --seed--
@@ -22,7 +22,7 @@ assert.match(code, /if\s*\((\s*\!userData\?\.currentSong\s*|\s*userData\?\.curre
You should call the `playSong` function with `userData?.songs[0].id` inside your `if` block.
```js
assert.match(code, /if\s*\((\s*\!userData\?\.currentSong\s*|\s*userData\?\.currentSong\s*===\s*null\s*|\s*userData\?\.currentSong\s*===\s*undefined\s*)\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/)
assert.match(code, /if\s*\((\s*\!userData\?\.currentSong\s*|\s*userData\?\.currentSong\s*===\s*null\s*|\s*userData\?\.currentSong\s*===\s*undefined\s*)\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/)
```
# --seed--
@@ -16,20 +16,20 @@ This ensures that the currently playing song will continue to play when the play
You should not modify the existing `if` statement and its content.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/)
```
You should add an `else` block to your `if` statement.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{/)
```
You should call the `playSong` function with `userData?.currentSong.id` in the `else` block of your `if` statement.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*playSong\(\s*userData\?\.currentSong\.id\s*\);?\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*playSong\(\s*userData\?\.currentSong\.id\s*\)\s*;?\s*\}/)
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*/)
Your `pauseSong` function should be empty.
```js
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -16,13 +16,13 @@ To store the current time of the song when it is paused, set the `songCurrentTim
You should not modify the existing `pauseSong` function and its content.
```js
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\};?/)
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/)
```
You should assign `audio.currentTime` to `userData.songCurrentTime`.
```js
assert.match(code, /userData\.songCurrentTime\s*=\s*audio\.currentTime;?/)
assert.match(code, /userData\.songCurrentTime\s*=\s*audio\.currentTime\s*;?/)
```
# --seed--
@@ -16,13 +16,13 @@ To finally pause the song, use the `pause()` method on the `audio` variable. `pa
You should not modify the existing `pauseSong` function and its content.
```js
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\.songCurrentTime\s*=\s*audio\.currentTime;?\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\.songCurrentTime\s*=\s*audio\.currentTime\s*;?\s*.*\s*.*\s*\}\s*;?/)
```
You should use the `classList` property and the `remove()` method to remove the class `playing` from the `playButton`.
```js
assert.match(code, /playButton\.classList\.remove\(\s*('|")playing\1\s*\);?/)
assert.match(code, /playButton\.classList\.remove\(\s*('|")playing\1\s*\)\s*;?/)
```
You should use the `pause()` method on your `audio` variable.
@@ -16,13 +16,13 @@ To finally play the song, use the `play()` method on the `audio` variable. `play
You should use the `classList` property and the `add` method to add the class `playing` to `playButton`.
```js
assert.match(code, /playButton\.classList\.add\(\s*("|')playing\1\s*\);?/)
assert.match(code, /playButton\.classList\.add\(\s*("|')playing\1\s*\)\s*;?/)
```
You should use the `play()` method on the `audio` variable.
```js
assert.match(code, /audio\.play\(\s*\);?/)
assert.match(code, /audio\.play\(\s*\)\s*;?/)
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*/)
Your `playNextSong` function should be empty.
```js
assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -16,7 +16,7 @@ If the condition is true, call the `playSong` function with the `id` of the firs
You should not modify the existing `playNextSong` function and its content.
```js
assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*.*\s*\}\s*;?/)
```
You should create an `if` statement with the condition `userData?.currentSong === null`.
@@ -32,7 +32,7 @@ You should call the `playSong` function with `userData?.songs[0].id` inside the
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/)
```
# --seed--
@@ -16,7 +16,7 @@ You should not modify the existing `if` statement.
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/)
```
You should add an `else` to the existing `if` statement.
@@ -24,7 +24,7 @@ You should add an `else` to the existing `if` statement.
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*/)
```
You should set the `currentSongIndex` constant to `getCurrentSongIndex()` inside the `else` block.
@@ -32,7 +32,7 @@ You should set the `currentSongIndex` constant to `getCurrentSongIndex()` inside
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*\}/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*\}/)
```
@@ -20,7 +20,7 @@ You should not modify the existing `if` statement, its `else` block, and content
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/)
```
You should assign `userData?.songs[currentSongIndex + 1]` to a `nextSong` constant.
@@ -28,7 +28,7 @@ You should assign `userData?.songs[currentSongIndex + 1]` to a `nextSong` consta
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*/)
```
You should call the `playSong` function with `nextSong.id`.
@@ -36,7 +36,7 @@ You should call the `playSong` function with `nextSong.id`.
```js
const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);')
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*playSong\(\s*nextSong\.id\s*\);?\s*\}/)
assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*playSong\(\s*nextSong\.id\s*\)\s*;?\s*\}/)
```
@@ -32,7 +32,7 @@ assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*/)
Your `playPreviousSong` function should be empty.
```js
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -28,19 +28,19 @@ assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s
You should have `return` inside the block of your `if` statement.
```js
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?/)
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?/)
```
Your `if` statement should have an `else` block.
```js
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*/)
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*/)
```
You should call `getCurrentSongIndex` and assign it to `currentSongIndex` inside the `else` block of your `if` statement.
```js
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/)
assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/)
```
@@ -14,19 +14,19 @@ To get the previous song, subtract `1` from the `currentSongIndex` of `userData?
You should not modify the existing `if` statement and its content.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/)
```
You should assign `userData?.songs[currentSongIndex - 1]` to a `previousSong` constant.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*/)
```
You should call the `playSong` function with `previousSong.id`.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*playSong\(\s*previousSong\.id\s*\);?\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*playSong\(\s*previousSong\.id\s*\)\s*;?\s*\}/)
```
# --seed--
@@ -40,7 +40,7 @@ assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\
You should use the `querySelectorAll()` method to select the `.playlist-song` element and assign it to the `playlistSongElements` constant.
```js
assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\);?\s*\};?/)
assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\)\s*;?\s*\}\s*;?/)
```
# --seed--
@@ -16,19 +16,19 @@ Use `getElementById()` to get the `id` of the currently playing song, then use t
You should not modify the existing `highlightCurrentSong` function and its content.
```js
assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*\s{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\);?\s*/)
assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*\s{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\)\s*;?\s*/)
```
You should use `document.getElementById()` and pass in `` `song-${userData?.currentSong?.id}` ``.
```js
assert.match(code, /document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\);?\s*\};?/)
assert.match(code, /document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\)\s*;?\s*\}\s*;?/)
```
You should assign your `getElementById()` to a `songToHighlight` constant.
```js
assert.match(code, /const\s+songToHighlight\s*=\s*document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\);?\s*\};?/)
assert.match(code, /const\s+songToHighlight\s*=\s*document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\)\s*;?\s*\}\s*;?/)
```
# --seed--
@@ -39,7 +39,7 @@ assert.match(code, /playlistSongElements\.forEach\(\s*(\(songEl\s*\)|songEl)\s*=
Your `forEach` should have an empty pair of curly braces.
```js
assert.match(code, /playlistSongElements\.forEach\(\s*(\(songEl\s*\)|songEl)\s*=>\s*\{\s*\}\s*\);?/)
assert.match(code, /playlistSongElements\.forEach\(\s*(\(songEl\s*\)|songEl)\s*=>\s*\{\s*\}\s*\)\s*;?/)
```
# --seed--
@@ -32,7 +32,7 @@ assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*/)
Your `setPlayerDisplay` function should be empty.
```js
assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -16,31 +16,31 @@ Access the `#player-song-title` and `#player-song-artist` elements with the `get
You should not modify the existing `setPlayerDisplay` function and its content.
```js
assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\}\s*;?/)
```
You should use `document.getElementById()` to get the `#player-song-title` element.
```js
assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\);?/);
assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\)\s*;?/);
```
You should assign the `#player-song-title` element to the variable `playingSong`. Don't forget to use `const` to declare the variable.
```js
assert.match(code, /const\s+playingSong\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\);?/);
assert.match(code, /const\s+playingSong\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\)\s*;?/);
```
You should use `document.getElementById()` to get the `#player-song-artist` element.
```js
assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\);?/);
assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\)\s*;?/);
```
You should assign the `#player-song-artist` element to the variable `songArtist`. Don't forget to use `const` to declare the variable.
```js
assert.match(code, /const\s+songArtist\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\);?/);
assert.match(code, /const\s+songArtist\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\)\s*;?/);
```
# --seed--
@@ -14,25 +14,25 @@ Access the `userData?.currentSong?.title` and `userData?.currentSong?.artist` pr
You should access the `title` of `currentSong` from the `userData` object. Don't forget to use optional chaining.
```js
assert.match(code, /userData\?\.currentSong\?\.title;?/)
assert.match(code, /userData\?\.currentSong\?\.title\s*;?/)
```
You should assign the `title` of the `currentSong` to a `currentTitle` constant.
```js
assert.match(code, /const\s+currentTitle\s*=\s*userData\?\.currentSong\?\.title;?/)
assert.match(code, /const\s+currentTitle\s*=\s*userData\?\.currentSong\?\.title\s*;?/)
```
You should access the `artist` of `currentSong` from the `userData` object. Don't forget to use optional chaining.
```js
assert.match(code, /userData\?\.currentSong\?\.artist;?/)
assert.match(code, /userData\?\.currentSong\?\.artist\s*;?/)
```
You should assign the `artist` of the `currentSong` to a `currentArtist` constant.
```js
assert.match(code, /const\s+currentArtist\s*=\s*userData\?\.currentSong\?\.artist;?/)
assert.match(code, /const\s+currentArtist\s*=\s*userData\?\.currentSong\?\.artist\s*;?/)
```
# --seed--
@@ -33,7 +33,7 @@ assert.match(code, /playingSong\.textContent\s*/)
You should use the `ternary` operator to set the `textContent` property of `playingSong` to `currentTitle` or `""`.
```js
assert.match(code, /playingSong\.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1;?/)
assert.match(code, /playingSong\.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1\s*;?/)
```
You should chain the `textContent` property to `songArtist`.
@@ -45,7 +45,7 @@ assert.match(code, /songArtist\.textContent\s*/)
You should use the `ternary` operator to set the `textContent` property of `songArtist` to `currentArtist` or `""`.
```js
assert.match(code, /songArtist\.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1;?/)
assert.match(code, /songArtist\.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1\s*;?/)
```
# --seed--
@@ -16,7 +16,7 @@ Now you should see the song title and the artist show up in the display.
You should call the `setPlayerDisplay` function inside your `playSong` function.
```js
assert.match(code, /setPlayerDisplay\(\s*\);?/)
assert.match(code, /setPlayerDisplay\(\s*\)\s*;?/)
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*/)
Your `setPlayButtonAccessibleText` function should be empty.
```js
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -16,7 +16,7 @@ Don't forget to use optional chaining.
You should not modify the existing `setPlayButtonAccessibleText` and its content.
```js
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\};?/)
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/)
```
You should access `userData?.currentSong` or `userData?.songs[0]`.
@@ -16,7 +16,7 @@ Don't forget you need template interpolation here, so you need to use backticks.
You should not modify the existing `setPlayButtonAccessibleText` function and its content.
```js
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.currentSong\s*\|\|\s*userData\?\.songs\s*\[\s*0\s*\]\s*;?\s*.*\s*.*\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.currentSong\s*\|\|\s*userData\?\.songs\s*\[\s*0\s*\]\s*;?\s*.*\s*.*\s*.*\s*.*\s*\}\s*;?/)
```
You should use the `setAttribute()` method on `playButton`.
@@ -34,7 +34,7 @@ assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1/)
Your `setAttribute` method should have ``song?.title ? `Play ${song.title}` : "Play"`` as the second argument.
```js
assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1\s*,\s*song\?\.title\s*\?\s*`Play\s*\$\{song\.title\}`\s*:\s*('|")Play\2\s*\);?\s*/)
assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1\s*,\s*song\?\.title\s*\?\s*`Play\s*\$\{song\.title\}`\s*:\s*('|")Play\2\s*\)\s*;?\s*/)
```
# --seed--
@@ -14,7 +14,7 @@ Now, call the `setPlayButtonAccessibleText` function inside the `playSong` funct
You should call the `setPlayButtonAccessibleText` inside your `playSong` function.
```js
assert.match(code, /setPlayButtonAccessibleText\(\s*\);?/)
assert.match(code, /setPlayButtonAccessibleText\(\s*\)\s*;?/)
```
# --seed--
@@ -34,7 +34,7 @@ assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*/)
Your `shuffle` function should be empty.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -24,7 +24,7 @@ Use the `sort()` method on the `userData?.songs` array. Pass a callback to the m
You should not modify the existing `shuffle` function.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\};?/);
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\}\s*;?/);
```
You should use the `sort()` method on `userData?.songs`.
@@ -42,7 +42,7 @@ assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/)
The callback of your `sort()` method should return `Math.random() - 0.5`.
```js
assert.match(code, /userData\?.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\);?/);
assert.match(code, /userData\?.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\)\s*;?/);
```
# --seed--
@@ -18,13 +18,13 @@ Set `userData.currentSong` to `null` and `userData.songCurrentTime` to `0`.
You should set `userData.currentSong` to `null`.
```js
assert.match(code, /userData\.currentSong\s*=\s*null;?/)
assert.match(code, /userData\.currentSong\s*=\s*null\s*;?/)
```
You should set `userData.songCurrentTime` to `0`.
```js
assert.match(code, /userData\.songCurrentTime\s*=\s*0;?/)
assert.match(code, /userData\.songCurrentTime\s*=\s*0\s*;?/)
```
# --seed--
@@ -16,31 +16,31 @@ Call the `renderSongs` function and pass in `userData?.songs` as an argument. Al
You should not modify the existing `shuffle` function and its content.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*.*\s*.*\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*.*\s*.*\s*.*\s*.*\s*\}\s*;?/)
```
You should call the `renderSongs` function with `userData?.songs`.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*.*\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}\s*;?/)
```
You should call the `pauseSong` function.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*.*\s*.*\s*\}\s*;?/)
```
You should call the `setPlayerDisplay` function.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*.*\s*\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*.*\s*\}\s*;?/)
```
You should call the `setPlayButtonAccessibleText` function.
```js
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*\};?/)
assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*\}\s*;?/)
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1/)
You should pass in `shuffle` as the second value of your `click` event listener.
```js
assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1\s*,\s*shuffle\s*\);?/)
assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1\s*,\s*shuffle\s*\)\s*;?/)
```
# --seed--
@@ -40,7 +40,7 @@ assert.match(code, /const\s+deleteSong\s*=\s*\(?\s*id/)
Your `deleteSong` function should be empty.
```js
assert.match(code, /const\s+deleteSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\}\s*;?/)
```
# --seed--
@@ -27,7 +27,7 @@ Use the `filter()` method on `userData?.songs`. Pass in `song` as the parameter
You should not modify the existing `deleteSong` function.
```js
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*.*\s*\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/)
```
You should use the `filter()` method on `userData?.songs`.
@@ -18,25 +18,25 @@ After that, call the `highlightCurrentSong` function to highlight the current so
You should not modify the existing `deleteSong` function and its content.
```js
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*.*\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}\s*;?/)
```
You should call the `renderSongs` function with `userData?.songs`.
```js
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*.*\s*.*\s*\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*.*\s*.*\s*\}\s*;?/)
```
You should call the `highlightCurrentSong` function.
```js
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*highlightCurrentSong\(\s*\);?\s*.*\s*\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*highlightCurrentSong\(\s*\)\s*;?\s*.*\s*\}\s*;?/)
```
You should call the `setPlayButtonAccessibleText` function.
```js
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*highlightCurrentSong\(\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*\};?/)
assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*highlightCurrentSong\(\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*\}\s*;?/)
```
# --seed--
@@ -22,25 +22,25 @@ assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{
You should set `userData.currentSong` to `null`.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*.*\s*.*\s*.*\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*.*\s*.*\s*.*\s*\}/)
```
You should set `userData.songCurrentTime` to `0`.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*.*\s*.*\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*.*\s*.*\s*\}/)
```
You should call the `pauseSong` function.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*pauseSong\(\s*\);?\s*.*\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*pauseSong\(\s*\)\s*;?\s*.*\s*\}/)
```
You should call the `setPlayerDisplay` function.
```js
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*\}/)
```
# --seed--
@@ -39,13 +39,13 @@ assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*.*
You should use the `createElement` method to create a `button`.
```js
assert.match(code, /document\.createElement\(\s*('|")button\1\s*\);?/)
assert.match(code, /document\.createElement\(\s*('|")button\1\s*\)\s*;?/)
```
You should assign your newly created `button` element to a `resetButton` constant.
```js
assert.match(code, /const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\);?/)
assert.match(code, /const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\)\s*;?/)
```
# --seed--
@@ -18,7 +18,7 @@ Set the `id` attribute of `resetButton` to `reset` and its `aria-label` attribut
You should not modify the existing `if` statement and its content.
```js
assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\);?\s*.*\s*.*\s*.*\s*\}/)
assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}/)
```
You should use `resetButton.id` to create an `id` attribute named `reset` for the `resetButton`.
@@ -30,7 +30,7 @@ assert.match(code, /resetButton\.id\s*=\s*('|")reset\1/)
You should use `resetButton.ariaLabel` to create an `aria-label` attribute named `Reset playlist` for the `resetButton`.
```js
assert.match(code, /resetButton\.ariaLabel\s*=\s*('|")Reset\s+playlist\1;?/)
assert.match(code, /resetButton\.ariaLabel\s*=\s*('|")Reset\s+playlist\1\s*;?/)
```
# --seed--
@@ -32,7 +32,7 @@ assert.match(code, /resetButton\.appendChild\(/)
You should pass in `resetText` as the value of your first `appendChild()`.
```js
assert.match(code, /resetButton\.appendChild\(\s*resetText\s*\);?/)
assert.match(code, /resetButton\.appendChild\(\s*resetText\s*\)\s*;?/)
```
You should use the `appendChild()` method on `playlistSongs`.
@@ -44,7 +44,7 @@ assert.match(code, /playlistSongs\.appendChild\(/)
You should pass in `resetButton` as the value of your second `appendChild()`.
```js
assert.match(code, /playlistSongs\.appendChild\(\s*resetButton\s*\);?/)
assert.match(code, /playlistSongs\.appendChild\(\s*resetButton\s*\)\s*;?/)
```
# --seed--
@@ -28,7 +28,7 @@ assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1/)
The callback function of your event listener should use arrow syntax and have an empty pair of curly braces.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/)
```
# --seed--
@@ -16,7 +16,7 @@ To reset the playlist to its original state, spread `allSongs` into an array and
You should not modify the existing event listener and its content.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*\)\s*;?/)
```
You should assign `[...allSongs]` to `userData.songs`.
@@ -22,25 +22,25 @@ Remove the reset button from the playlist by calling the `remove()` method on th
You should not modify the existing event listener and its content.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*.*\s*.*\s*.*\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*.*\s*.*\s*.*\s*\}\s*\)\s*;?/)
```
You should call the `renderSongs` function with `sortSongs()`.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\)\s*\);?\s*.*\s*.*\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*.*\s*.*\s*\}\s*\)\s*;?/)
```
You should call the `setPlayButtonAccessibleText` function.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\)\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*.*\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*.*\s*\}\s*\)\s*;?/)
```
You should use the `remove()` method to remove the `resetButton` from the DOM.
```js
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\)\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*resetButton\.remove\(\s*\);?\s*\}\s*\);?/)
assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*resetButton\.remove\(\s*\)\s*;?\s*\}\s*\)\s*;?/)
```
# --seed--

Some files were not shown because too many files have changed in this diff Show More