JavaScript, Programming, Software Development, Web Development, Software Engineering.
(let j = 0; j < arr.length - i - 1; j++)) compares adjacent elements. If arr[j] is greater than arr[j + 1], the elements are swapped using array destructuring. The function returns the sorted array. Result: The example sorts the unsortedArray in ascending order and prints the sorted sortedArray.