From 5d12638ab59be001f01c14473193788ec7305b58 Mon Sep 17 00:00:00 2001 From: Sid Date: Wed, 17 Oct 2018 11:13:27 +0800 Subject: [PATCH] BubbleSort: use Destructuring assignment to swap values (#226) * BubbleSort: use Destructuring assignment to swap values * lint: add semi --- src/algorithms/sorting/bubble-sort/BubbleSort.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/algorithms/sorting/bubble-sort/BubbleSort.js b/src/algorithms/sorting/bubble-sort/BubbleSort.js index 4d3f1569..d78ebcbd 100644 --- a/src/algorithms/sorting/bubble-sort/BubbleSort.js +++ b/src/algorithms/sorting/bubble-sort/BubbleSort.js @@ -19,9 +19,7 @@ export default class BubbleSort extends Sort { // Swap elements if they are in wrong order. if (this.comparator.lessThan(array[j + 1], array[j])) { - const tmp = array[j + 1]; - array[j + 1] = array[j]; - array[j] = tmp; + [array[j], array[j + 1]] = [array[j + 1], array[j]]; // Register the swap. swapped = true;