Test
unknown
javascript
3 years ago
860 B
4
Indexable
// Imagine you're developing a statistics system for an athletic federation. You're processing results from a race in the following format: // "01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|17" // These are 5 racers and their race time as HH|MM|SS // Your task is to parse the input, calculate maximum/minimum and average time. // You can choose any programming language supported by codepad.io but on our side…we are fans of JavaScript. const times = ['01:15:59', '01:47:06', '01:17:20', '01:32:34', '02:03:17', '00:30:15']; times.sort(function(a,b) { return new Date('1970/01/01 ' + a) - new Date('1970/01/01 ' + b); }); // const average = (times) => times.reduce((a, b) => a + b) / times.length; console.log("The best time :", times[0] ); console.log("The worst time :", times[times.length - 1]); // console.log("The average time :", average);
Editor is loading...