Skip to content

Commit f46a82b

Browse files
author
Muhammad Usman
committed
small refactor in bubble sort for better readablity
1 parent a08b842 commit f46a82b

File tree

2 files changed

+4266
-1
lines changed

2 files changed

+4266
-1
lines changed

src/algorithms/sorting/bubble-sort/BubbleSort.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default class BubbleSort extends Sort {
55
// Flag that holds info about whether the swap has occur or not.
66
let swapped = false;
77
// Clone original array to prevent its modification.
8-
const array = originalArray.slice(0);
8+
const array = [...originalArray];
99

1010
for (let i = 0; i < array.length; i += 1) {
1111
swapped = false;

0 commit comments

Comments
 (0)