- script.js
JavaScript
var expectedUsers = 1000;
var usersByDay = [812, 1360, 657, 1247];
// Drawing the traffic graph
muffin.plot(usersByDay, expectedUsers);
for (var i = 0; i <= usersByDay.length - 1; i++) {
console.log(usersByDay[i]);
}
// Calculating the average traffic value
var averageUsers = 0;
console.log('Average traffic: ' + averageUsers);
if (averageUsers > expectedUsers) {
console.log('Traffic is amazing. Keep up the good work!');
} else {
console.log('Traffic is so-so. You need to try harder!');
}
Result
Goalscompleted
- Before the loop, add a variable
totalUsers
with a zero value. - Inside the loop, remove console log and increase the value of the variable
totalUsers
byusersByDay[i]
. - Inside the loop, log the variable
totalUsers
in the console.
Comments