You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* getHighestAndLowest: find the highest and lowest temperature from these thousands values
* @temperatyres: parameter is an array
*/
function getHighestAndLowest(temperatures) {
// Your code here
var func = function(temperatures) {
var lowestTemp = temperatures[0];
var highestTemp = temperatures[temperatures.length - 1];
for (var i=1, len = temperatures.length-1; i<len; i++) {
if (lowestTemp.value > temperatures[i].value) {
lowestTemp = temperatures[i]
}
if (highestTemp.value < temperatures[i].value) {
highestTemp = temperatures[i]
}
}
return { "lowestTemp":lowestTemp, "highestTemp": highestTemp }
}
var res = func(temperatures)
return formatMyResult(res.lowestTemp.value, res.highestTemp.value);
}
/** DO NOT TOUCH THIS */
function formatMyResult(min, max) {
return 'Les températures se situent entre ' + min + '°C et ' + max + '°C';
}
var request = require("request");
request({
url: 'http://ns323481.ip-37-187-0.eu/coding/temperature10000.json',
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
console.time('temperatures');
var result = getHighestAndLowest(response.body);
console.timeEnd('temperatures');
console.log('Result: ' + result);
}
})
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: