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.
2 parents f6c35bd + c977d81 commit 370361aCopy full SHA for 370361a
Sorts/bogoSort.js
@@ -4,13 +4,13 @@
4
*/
5
Array.prototype.isSorted = function() {
6
7
- var length = this.length;
+ let length = this.length;
8
9
if (length < 2) {
10
return true;
11
}
12
13
- for (var i = 0; i < length - 1; i++) {
+ for (let i = 0; i < length - 1; i++) {
14
if (this[i] > this[i + 1]) {
15
return false;
16
@@ -23,9 +23,9 @@ Array.prototype.isSorted = function() {
23
24
Array.prototype.shuffle = function() {
25
26
- for (var i = this.length; i; i--) {
27
- var m = Math.floor(Math.random() * i);
28
- var n = this[i - 1];
+ for (let i = this.length -1; i; i--) {
+ let m = Math.floor(Math.random() * i);
+ let n = this[i - 1];
29
this[i - 1] = this[m];
30
this[m] = n;
31
0 commit comments