We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da50af3 commit b135a51Copy full SHA for b135a51
Sorts/SelectionSort.js
@@ -12,7 +12,13 @@ export const selectionSort = (list) => {
12
if (!Array.isArray(list)) {
13
throw new TypeError('Given input is not an array')
14
}
15
- const items = [...list] // We don't want to modify the original array
+
16
+ if (list.length === 0) {
17
+ return []
18
+ }
19
20
+ const items = [...list]
21
22
const length = items.length
23
for (let i = 0; i < length - 1; i++) {
24
if (typeof items[i] !== 'number') {
0 commit comments