From 8b7c5fdc57249dd0e44bd0507bd3c5174e74a96f Mon Sep 17 00:00:00 2001 From: Rak Laptudirm <68542775+raklaptudirm@users.noreply.github.com> Date: Fri, 21 May 2021 11:52:37 +0530 Subject: [PATCH] style(InsertionSort.js): Changed var to let (scope taken into account) --- Sorts/InsertionSort.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sorts/InsertionSort.js b/Sorts/InsertionSort.js index d73f179d3..5812acf81 100644 --- a/Sorts/InsertionSort.js +++ b/Sorts/InsertionSort.js @@ -7,9 +7,10 @@ function insertionSort (unsortedList) { const len = unsortedList.length for (let i = 1; i < len; i++) { + let j const tmp = unsortedList[i] // Copy of the current element. /* Check through the sorted part and compare with the number in tmp. If large, shift the number */ - for (var j = i - 1; j >= 0 && (unsortedList[j] > tmp); j--) { + for (j = i - 1; j >= 0 && (unsortedList[j] > tmp); j--) { // Shift the number unsortedList[j + 1] = unsortedList[j] }