fixed a leak and added the let-statement

This commit is contained in:
Christian Bender
2018-03-30 23:19:43 +02:00
parent b9d749acd2
commit c977d81dd7

View File

@ -4,13 +4,13 @@
*/ */
Array.prototype.isSorted = function() { Array.prototype.isSorted = function() {
var length = this.length; let length = this.length;
if (length < 2) { if (length < 2) {
return true; return true;
} }
for (var i = 0; i < length - 1; i++) { for (let i = 0; i < length - 1; i++) {
if (this[i] > this[i + 1]) { if (this[i] > this[i + 1]) {
return false; return false;
} }
@ -23,9 +23,9 @@ Array.prototype.isSorted = function() {
*/ */
Array.prototype.shuffle = function() { Array.prototype.shuffle = function() {
for (var i = this.length; i; i--) { for (let i = this.length -1; i; i--) {
var m = Math.floor(Math.random() * i); let m = Math.floor(Math.random() * i);
var n = this[i - 1]; let n = this[i - 1];
this[i - 1] = this[m]; this[i - 1] = this[m];
this[m] = n; this[m] = n;
} }