Tell us what’s happening:
idk what else to do, i thought i was following the directions, EXACT copy of what is supposed to be in the for loop conditions, checked the console and this lesson has some contradictory ass wording “iterate everything except the last thing, but make the j increase by 1”. its the same thing then
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const bubbleSort = (array) => {
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array.length; j++) {
}
}
}
// User Editable Region
Your browser information:
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 OPR/109.0.0.0
Challenge Information:
Learn Basic Algorithmic Thinking by Building a Number Sorter - Step 18
This loop should iterate through every element in the array except the last one.
Are you omitting the final element of the array? What is the index of the final element of the array? Is that index in the range covered by j
?
i dont know what you mean by that
Can you be more specific? Do you know what the array
is? Do you know what an index is? ect
i know what and array is but i am not sure how to access the last part of it, all of this wording is confusing af to me ngl
1 Like
The first element of the array is at index 0. That’s why i
and j
start at 0. The last index of the array is at the end. How many elements are in this array?
1 Like
as far as i know this is just an empty array in this lesson. if i wanted to reverse index to get the last element i would do that but im not sure what this is asking me to do or how to put this into the code
I don’t understand what “reverse index to get the last element” means?
There is a piece of syntax you are using that says how many elements are in the array.
You don’t understand what piece of syntax is telling you how long the array is? In that case I would go back to Step 1 and do this project more slowly.
remove this post, its been solved, all i had to do was shorten the array by 1 not exclude the last element in the array. how hard is it to say that?
4 Likes
You should not be shortening the array in any way.
“not include the last element” or “exclude the last element”
That is what the instructions say:
every element in the array except the last one
Glad you got it!
1 Like