I am getting infinite while loops and I don't understand why

Arkannine

New Member
\[code\]var object = new Object();object.bill = new Object();object.bill["First Name"] = 'BILL';object.bill["Last Name"] = "GATES";object.bill["Number"] = "985";object.bill["Address"] = ["1ST STREET", "1ST AVENUE", "NEW YORK"];object.bob = new Object();object.bob["First Name"] = 'BOB';object.bob["Last Name"] = "MARLEY";object.bob["Number"] = "985";object.bob["Address"] = ["1ST STREET", "1ST AVENUE", "NEW YORK"];object.steve = new Object();object.steve["First Name"] = 'STEVE';object.steve["Last Name"] = "JOBS";object.steve["Number"] = "985";object.steve["Address"] = ["1ST STREET", "1ST AVENUE", "CUPERTINO"];var list = function(list) { for (var friend in list) { console.log(friend); } };var i = 0;var f = 0;var a = 0;var While = function(parameter) { for (var friend in object) { while ((object[friend][parameter])[i + a] != name[f] && (i + a) <= (object[friend][parameter]).length) { i++; if ((i + a) == (object[friend][parameter]).length) break; } while ((object[friend][parameter])[i + a] == name[f]) { f++; a++; if ((object[friend][parameter]).length == name.length) { console.log(object[friend]); i = 0; f = 0; a = 0; break; } if ((object[friend][parameter])[i + a] !== name[f]) { i = 0; f = 0; a = 0; break; } } } };var search = function(name) { for (var friend in object) { //to make sure your contact is in the list While("First Name"); While("Last Name"); While("Number"); for (var j = 0; j < 4; j++) { while (((object[friend]["Address"])[j])[i + a] != name[f] && ((object[friend]["Address"])[j]).length >= (i + a)) { i++; if (((object[friend]["Address"])[j]).length == (i + a)) { break; } } while (((object[friend]["Address"])[j])[i + a] == name[f]) { f++; a++; if (((object[friend]["Address"])[j]).length == name.length) { console.log(object[friend]); i = 0; f = 0; a = 0; break; } if (((object[friend]["Address"])[j])[i + a] != name[f]) { i = 0; f = 0; a = 0; break; } } } } };var contact = prompt("Enter a part of your contact's info").toUpperCase();search(contact, object);\[/code\]I keep getting infinite while loops I dont understand where the problem is...I just recently tried to nest if statements in while loops....I'm trying to build sort of a search engineAny ideas? Please help thank you!!
 
Back
Top