java script debugging help

function bubbleSort() {

var arrayVal = new Array(5, 88, 77, 55, 44, 22, 11, 10, 9, 8, 7, 6, 100, 99);

var hasStopped = false;

while (hasStopped = false) {
hasStopped = true;

for (var index = 0; index < hasStopped; j++) {

if (arrayVal[index] < arrayVal[index + 1]) {
swap(index, index + 1);
hasStopped = false;
}
}
}
printArray("Bubble Sort: ", "arrayVal");


function insertionSort() {

var arrayVal = new Array(5, 88, 77, 55, 44, 22, 11, 10, 9, 8, 7, 6, 100, 99);

var index = 3;

var size = arrayVal.length;

while (index < size) {

var start = index;

var toInsert = arrayVal[index];

while ((start > 0) && (arrayVal[start - 1] < arrayVal[start])) {

arrayVal[start] = arrayVal[start - 1];
start--;
}
arrayVal[start] = toInsert;
index++;
}
printArray("Insertion Sort: ", arrayVal);
}


function selectionSort() {

var arrayVal = new Array(5, 1, 77, 2, 44, 22, 11, 10, 9, 36, 7, 6, 100, 99, 4);

var size = arrayVal.length;

var index = 1;
while (index < size-1) {

var start = index;
var lowestNumPos = start;

while (start < size-1) {
if (arrayVal[lowestNumPos] > arrayVal[start + 1])
lowestNumPos = start;

start++;
}

if(lowestNumPos !== index)
swap(index, lowestNumPos, arrayVal);

index++;
}
printArray("Selection Sort: ", arrayVal);
}

function swap(first, second, arrayVal) {
var temp = arrayVal[first];
arrayVal[first] = arrayVal[second];
arrayVal[second] = temp;
}

function printArray(sorting, arrayVal) {
var div = document.getElementById("mySorting");
div.innerHTML += sorting + " [" + arrayVal + "]<br/>"; //innerHTML usage = needed to write contents(text) into HTML element


function callSorting() {
bubbleSort();
insertionSort();
selectionSort();

var h2 = document.getElementById("msg");
h2.innerHTML = "GOOOOD, NO MORE RUN-TIME BUGS!!! MAKE SURE YOUR NUMBERS ARE SORTED THOUGH ... ;-)";
}



window.onerror = function(err, file, line) {
var p = document.getElementById("mess");
p.innerHTML = 'The following error occured: <br/>' + err + '<br/>' +
'At line: ' + line;
return true;
}

This is a C++ forum.
This is a C++ forum. But I believe you could debug it in Chrome.
Topic archived. No new replies allowed.