Skip to content

Commit 969902a

Browse files
author
Christian Bender
committed
added let-statment
1 parent b9d749a commit 969902a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Sorts/heapSort.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88
Array.prototype.heapify = function (index, heapSize) {
99

10-
var largest = index;
11-
var leftIndex = 2 * index + 1;
12-
var rightIndex = 2 * index + 2;
10+
let largest = index;
11+
let leftIndex = 2 * index + 1;
12+
let rightIndex = 2 * index + 2;
1313

1414
if (leftIndex < heapSize && this[leftIndex] > this[largest]) {
1515
largest = leftIndex;
@@ -20,7 +20,7 @@ Array.prototype.heapify = function (index, heapSize) {
2020
}
2121

2222
if (largest !== index) {
23-
var temp = this[largest];
23+
let temp = this[largest];
2424
this[largest] = this[index];
2525
this[index] = temp;
2626

@@ -35,13 +35,13 @@ Array.prototype.heapify = function (index, heapSize) {
3535
*/
3636
function heapSort(items) {
3737

38-
var length = items.length;
38+
let length = items.length;
3939

40-
for (var i = Math.floor(items.length / 2) - 1; i > -1; i--) {
40+
for (let i = Math.floor(length / 2) - 1; i > -1; i--) {
4141
items.heapify(i, length);
4242
}
43-
for (var j = length -1; j > 0; j--) {
44-
var tmp = items[0];
43+
for (let j = length -1; j > 0; j--) {
44+
let tmp = items[0];
4545
items[0] = items[j];
4646
items[j] = tmp;
4747
items.heapify(0, j);

0 commit comments

Comments
 (0)