Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 17

Tell us what’s happening:

Create a variable called sortedValues and assign the value of calling bubbleSort.Also insert sortedValues as the argument of UpdateUI() `const sortedValues=bubbleSort() UpdateUI(sortedValues);`

``````<!-- file: index.html -->

``````
``````/* file: styles.css */

``````
``````/* file: script.js */
// User Editable Region

const sortedValues = bubbleSort();
updateUI(sortedValues);

// User Editable Region
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0`

Challenge Information:

Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 17

What are you sorting here?

I have created a variable sortedValues and assigned it to the call of bubbleSort.

Agreed, but look at the `bubbleSort` function you created. How many parameters does it take? What are those parameters for?

`bubbleSort()`am assigning it to `sortedValues`Or maybe I am not getting the instructions.

This is the `bubbleSort` function in your code:

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

How do you need to call this function so it will sort an array?

Just to clarify,We call functions using`()`.`bubbleSort()` is how I would call this function.Maybe am missing a point?

Inside the `bubbleSort` function, it is using the variable `array`. Where did it get that variable from?

Let me ask you this, in the next line you are calling the `updateUI` function as:

``````updateUI(sortedValues);
``````

This is correct. Why are you passing `sortedValues` into that function?

1 Like

`inputValues.`Thank you. I understood the logic now.

Your last sentence did the magic.