mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(curriculum): add quotes to strings in JS number sorter (#54212)
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ dashedName: step-1
|
||||
|
||||
In this project, you will be building a number sorter. The HTML and CSS have been provided for you. Feel free to explore them.
|
||||
|
||||
When you are ready, declare a `sortButton` variable and assign it the value of `.getElementById()` with the argument `sort`.
|
||||
When you are ready, declare a `sortButton` variable and assign it the value of `.getElementById()` with the argument `"sort"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,7 +19,7 @@ You should declare a `sortButton` variable with `const`.
|
||||
assert.match(code, /const\s+sortButton\s*=/);
|
||||
```
|
||||
|
||||
You should call `document.getElementById()` with the argument `sort`.
|
||||
You should call `document.getElementById()` with the argument `"sort"`.
|
||||
|
||||
```js
|
||||
assert.match(code, /document\.getElementById\(\s*('|"|`)sort\1\s*\)/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-4
|
||||
|
||||
# --description--
|
||||
|
||||
To test your code as you write it, mount an event listener to your `sortButton` element. It should listen for the `click` event, and take `sortInputArray` as the callback.
|
||||
To test your code as you write it, mount an event listener to your `sortButton` element. It should listen for the `"click"` event, and take `sortInputArray` as the callback.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ You should call the `.addEventListener()` method on your `sortButton` element.
|
||||
assert.match(code, /sortButton\s*\.\s*addEventListener\s*\(/);
|
||||
```
|
||||
|
||||
Your `.addEventListener()` method should listen for the `click` event.
|
||||
Your `.addEventListener()` method should listen for the `"click"` event.
|
||||
|
||||
```js
|
||||
assert.match(code, /sortButton\s*\.\s*addEventListener\s*\(\s*('|"|`)click\1\s*,/);
|
||||
|
||||
+2
-2
@@ -9,11 +9,11 @@ dashedName: step-5
|
||||
|
||||
Back in your `sortInputArray` function, you need to get the values from your `select` elements. Since they all have the class `values-dropdown`, you can query them all at once.
|
||||
|
||||
Use `document.getElementsByClassName()` to get all the elements with the class `values-dropdown`. Assign that to an `inputValues` variable.
|
||||
Use `document.getElementsByClassName()` to get all the elements with this class by passing in the argument `"values-dropdown"`. Assign that to an `inputValues` variable with `const`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use `document.getElementsByClassName()` to get all the elements with the class `values-dropdown`.
|
||||
You should use `document.getElementsByClassName()` to get all the elements with the class `"values-dropdown"`.
|
||||
|
||||
```js
|
||||
assert.match(sortInputArray.toString(), /document\.getElementsByClassName\(\s*('|"|`)values-dropdown\1\s*\)/);
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ dashedName: step-26
|
||||
|
||||
Inside your nested `for` loop, add a `console.log()` call to check the values of `array`, `array[j]`, and `array[minIndex]` at each iteration. You can click the `Sort` button to see how your algorithm is traversing the array.
|
||||
|
||||
Then write an `if` statement that checks if the value at `j` is smaller than the value at `minIndex`. If it is, set `minIndex` to `j`.
|
||||
Then write an `if` statement that checks if the value at `array[j]` is smaller than the value at `array[minIndex]`. If it is, set `minIndex` to `j`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ dashedName: step-27
|
||||
|
||||
After your nested `for` loop, you've found the smallest value. You need to swap it with your current value.
|
||||
|
||||
Like you did in your bubble sort, use a `temp` variable to extract the value at `i`, then swap the values at `i` and `minIndex`.
|
||||
Like you did in your bubble sort, use a `temp` variable to extract the value at `array[i]`, then swap the values at `array[i]` and `array[minIndex]`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-33
|
||||
|
||||
# --description--
|
||||
|
||||
Declare a `currValue` variable and assign it the value at `i`. Then, declare a `j` variable and assign it `i - 1`. Your `j` variable should be re-assignable.
|
||||
Declare a `currValue` variable and assign it the value at `array[i]`. Then, declare a `j` variable and assign it `i - 1`. Your `j` variable should be re-assignable.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ You should declare a `currValue` variable with `const`.
|
||||
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*=/);
|
||||
```
|
||||
|
||||
You should assign `currValue` the value at `i`.
|
||||
You should assign `currValue` the value at `array[i]`.
|
||||
|
||||
```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*;?/);
|
||||
|
||||
Reference in New Issue
Block a user