curriculum/challenges/english/blocks/daily-coding-challenges-javascript/68c1a929005bf54d342aa8d4.md
For day three of Space Week, you are given an array of numbers representing distances (in kilometers) between yourself, satellites, and your home planet in a communication route. Determine how long it will take a message sent through the route to reach its destination planet using the following constraints:
sendMessage([300000, 300000]) should return 2.5.
assert.equal(sendMessage([300000, 300000]), 2.5);
sendMessage([384400, 384400]) should return 3.0627.
assert.equal(sendMessage([384400, 384400]), 3.0627);
sendMessage([54600000, 54600000]) should return 364.5.
assert.equal(sendMessage([54600000, 54600000]), 364.5);
sendMessage([1000000, 500000000, 1000000]) should return 1674.3333.
assert.equal(sendMessage([1000000, 500000000, 1000000]), 1674.3333);
sendMessage([10000, 21339, 50000, 31243, 10000]) should return 2.4086.
assert.equal(sendMessage([10000, 21339, 50000, 31243, 10000]), 2.4086);
sendMessage([802101, 725994, 112808, 3625770, 481239]) should return 21.1597.
assert.equal(sendMessage([802101, 725994, 112808, 3625770, 481239]), 21.1597);
function sendMessage(route) {
return route;
}
function sendMessage(route) {
let totalDistance = route.reduce((a, d) => a += d, 0);
const delay = (route.length - 1) * 0.5
const time = totalDistance / 300000
const total = time + delay;
return Number(total.toFixed(4))
}