function myMain() { var people = []; var inp; var i=0; var payroll = 0; var max = -Infinity; var maxName; while (true) { people[i++] = makePersonObject(); inp = prompt("more?"); if (inp == "no") { break; } } for (var p=0; p max) { max = people[p].payrate; maxName = people[p].name; } } alert("high rate: " + maxName); } function makePersonObject() { var person = {}; person.id = Number(prompt("id?")); person.name = prompt("name?"); person.hours = Number(prompt("hours worked?")); person.payrate = Number(prompt("pay per hour?")); // how to add a function to an object: person.pay = function () { return (this.hours * this.payrate); // this is the notation that says look inside the obejct you are talking to. }; return person; } myMain();