Hi!
I just get to one part of the code, but I don’t know how to make it run for more values of input…
Can you tell me where I did wrong or what I’m missing here?..
Your code so far
function orbitalPeriod(arr) {
const GM = 398600.4418;
const earthRadius = 6367.4447;
let newArr = []
let func = arr.reduce((x) =>
2*Math.PI*Math.sqrt(((earthRadius + arr[x].avgAlt)**3)/GM), 0)
console.log(func)
for (let i = 0; i < arr.length; i++) {
newArr.push({
name: arr[i].name,
orbitalPeriod: Math.round(func)
})
}
console.log(newArr)
return newArr;
}
//orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]); ---- this works
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]) // but not this
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Map the Debris
Link to the challenge: