function lab09unknownLoopCountPart2() {
//Constants
var ONE_HUNDRED = 100;
var ZERO = 0;
//Variables
var employeeHourlyWage;
var hourlyMaximum = ZERO;
var hourlyMinimum = ZERO;
var totalHourlyWage = ZERO;
var records;
var counter = ZERO;
var average;
records = openEmployeePayrollRecords();
while (records.readNextRecord()) {
employeeHourlyWage = records.getEmployeeHourlyWage();
totalHourlyWage += employeeHourlyWage;
counter++;
average = totalHourlyWage/counter;
if (employeeHourlyWage < ONE_HUNDRED) {
hourlyMaximum = employeeHourlyWage;
}
if (employeeHourlyWage < ONE_HUNDRED) {
hourlyMinimum = employeeHourlyWage;
}
}
document.write("Average Hourly Wage: " + average + "<br />");
document.write("Maximum Hourly Wage: " + hourlyMaximum + "<br />");
document.write("Minimum Hourly Wage: " + hourlyMinimum + "<br />");
的記錄集是簡單地從15個號碼 - 30.我必須通過他們進行排序,找到最大,最小和平均。
我知道我的兩個IF語句是不正確的,我想知道如何使用Math.min和Math.max來檢查這個,沒有。
謝謝。
這就是我的教練讓我們聲明常量的方式,我不應該聲明它們嗎?我對你的意思有點困惑。 – TheStandardRGB 2010-11-23 20:15:21