mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +08:00
small refactor in bubble sort for better readablity
This commit is contained in:
parent
3e0ac7486c
commit
488b7a4c0e
@ -5,7 +5,7 @@ export default class BubbleSort extends Sort {
|
||||
// Flag that holds info about whether the swap has occur or not.
|
||||
let swapped = false;
|
||||
// Clone original array to prevent its modification.
|
||||
const array = originalArray.slice(0);
|
||||
const array = [...originalArray];
|
||||
|
||||
for (let i = 0; i < array.length; i += 1) {
|
||||
swapped = false;
|
||||
|
Loading…
Reference in New Issue
Block a user