Skip to content

Commit d44ffef

Browse files
committed
Cocktail Shaker Sort | Fixed 'standard' warnings and errors
1 parent 8d1278b commit d44ffef

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Sorts/CocktailShakerSort.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*/
1111

12-
/**
12+
/**
1313
* Doctests
1414
*
1515
* > cocktailShakerSort([5, 4, 1, 2, 3])
@@ -28,15 +28,13 @@ function cocktailShakerSort (items) {
2828
for (j = items.length - 1; j > i; j--) {
2929
if (items[j] < items[j - 1]) {
3030
[items[j], items[j - 1]] = [items[j - 1], items[j]]
31-
swapped = true
3231
}
3332
}
3433

3534
// Forwards
3635
for (j = 0; j < i; j++) {
3736
if (items[j] > items[j + 1]) {
3837
[items[j], items[j + 1]] = [items[j + 1], items[j]]
39-
swapped = true
4038
}
4139
}
4240
}
@@ -47,7 +45,7 @@ function cocktailShakerSort (items) {
4745
/**
4846
* Implementation of Cocktail Shaker Sort
4947
*/
50-
var array = [5, 6, 7, 8, 1, 2, 12, 14]
48+
const array = [5, 6, 7, 8, 1, 2, 12, 14]
5149
// Before Sort
5250
console.log('\n- Before Sort | Implementation of Cocktail Shaker Sort -')
5351
console.log(array)

0 commit comments

Comments
 (0)