Skip to content

Commit 370361a

Browse files
author
Christian Bender
authored
Merge pull request #52 from christianbender/changed_bogoSort
fixed a leak and added the let-statement
2 parents f6c35bd + c977d81 commit 370361a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sorts/bogoSort.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55
Array.prototype.isSorted = function() {
66

7-
var length = this.length;
7+
let length = this.length;
88

99
if (length < 2) {
1010
return true;
1111
}
1212

13-
for (var i = 0; i < length - 1; i++) {
13+
for (let i = 0; i < length - 1; i++) {
1414
if (this[i] > this[i + 1]) {
1515
return false;
1616
}
@@ -23,9 +23,9 @@ Array.prototype.isSorted = function() {
2323
*/
2424
Array.prototype.shuffle = function() {
2525

26-
for (var i = this.length; i; i--) {
27-
var m = Math.floor(Math.random() * i);
28-
var n = this[i - 1];
26+
for (let i = this.length -1; i; i--) {
27+
let m = Math.floor(Math.random() * i);
28+
let n = this[i - 1];
2929
this[i - 1] = this[m];
3030
this[m] = n;
3131
}

0 commit comments

Comments
 (0)