- script.js
JavaScript
var expectedUsers = 1000;
var usersByDay = [817, 1370, 752, 1247, 681, 1120, 915, 1281, 875, 1341, 757, 610, 812, 1170, 769, 1261, 845, 1289, 515, 1247, 845, 1311, 741, 1239, 812, 638, 877, 1242, 1159, 1372];
// Drawing the traffic graph
muffin.plot(usersByDay, expectedUsers);
// Summarizing traffic and analyzing the dips
var totalUsers = 0;
var minUsers = expectedUsers - 300;
var badDays = [];
for (var i = 0; i <= usersByDay.length - 1; i++) {
totalUsers += usersByDay[i];
if (usersByDay[i] < minUsers) {
badDays[i] = expectedUsers - usersByDay[i];
} else {
badDays[i] = 0;
}
}
muffin.plot(badDays, 300);
// Calculating the average traffic value
var averageUsers = totalUsers / usersByDay.length;
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
- Replace obsolete data with new ones (copy them from theory) and check if there are suspicious traffic dips.
Comments