Hi everyone! When I was taking the Number Sorter course, I have a question on the Bubble Sort method.

The code:

```
const bubbleSort = (array) => {
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array.length - 1; j++) {
if (array[j] > array[j + 1]) {
const temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
return array;
}
```

For this part:

```
const temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
```

I know that it is used to switch the position of the numbers.

However, since `array[j] = array[j + 1];`

, wouldn’t `const temp`

become `array[j+1]`

?

I’m just a bit confused at how the switching of position works, since adding three equations seems to result in `temp = array[j] = array[j+1]`

(i.e. all three are the same).

Thanks for your help!