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

Tell us what’s happening:

asked to use a for loop to iterate through every element in the array except the last one and to use j as my inner loop’s iterator variable, i am not clear on how to go about it

Your code so far

const bubbleSort = (array) => {
  for (let i = 0; i < array.length; i++) {

  }
}

Your browser information:

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

Challenge Information:

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

Add a second loop inside the current loop and use j for the loop variable. You can just copy and paste the current loop inside itself and update the variable name.

Then change the end condition to be one less than the array length so it stops before the last element.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.