-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
26 lines (18 loc) · 792 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const chalk = require('chalk');
function getLevelDifference(originalLevel, actualLevel) {
var difference = (actualLevel - originalLevel).toFixed(2);
return difference > 0 ? chalk.red(`+${difference}`) : chalk.green(difference);
}
function showMeasurementPerHour(measurements, quantity) {
let riverIndex = 0;
console.log('');
while (0 < quantity--) {
const dateHour = measurements[riverIndex].date.format("YYYY-MM-DD HH:mm");
const actualLevel = measurements[riverIndex].level;
const diff = getLevelDifference(measurements[riverIndex + 4].level, actualLevel);
console.log(`${dateHour} - ${actualLevel} metros (${diff})`);
riverIndex += 4;
}
console.log('');
}
exports.showMeasurementPerHour = showMeasurementPerHour;