Search:

Type: Posts; User: nomisco

Search: Search took 0.25 seconds.

  1. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    Again, you don't need to use this here: for (value = 0; value < (returnArray.length-1); value++); as length was already declared and assigned (arrayToSort.length) eariler.

    If it makes you feel any...
  2. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    for (counter = 0; counter < length; counter + 1)

    counter = counter + 1
  3. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    OK.

    Your final output will be document.write('Unsorted array ' + unsortedArray);

    Then you want to output the sorted array, so the next line will be document.write('Sorted array ' +...
  4. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    Well, bubbleSort(arrayToSort) is the argument for the bubbleSort function. So, you need bubbleSort(name of the array you are sorting).

    Hint: it's declared outside of the that function.
  5. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    OK, check these things - I won't directly give you the answer :rolleyes:

    1. Near the bottom you have 'length = unsortedArray' why?

    2. The line document.write('Sorted Array: ' + returnArray); is...
  6. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    For starters, although not an error, the length of the array (arrayToSort.length) has already been assigned to the variable 'length'.

    So, you should replace 'for (counter = 0; counter <...
  7. Replies
    17
    Views
    9,476

    Re: Javascript Bubble Sort

    I guess you're doing M150 as well?
Results 1 to 7 of 7