Intermediate Algorithm Scripting - Map the Debris

Tell us what’s happening:

Describe your issue in detail here.
What is actually incorrect in this code? console.log returns correct answers in both cases of tests. I am sorry to disturb you, but… if it is all about type of quotation marks it is kind of sad…

Your code so far

function orbitalPeriod(arr) {
let newArr =
const GM = 398600.4418;
const earthRadius = 6367.4447;
for (let p of arr) {
orbitalPeriod = Math.round(2Math.PIMath.sqrt(Math.pow(p.avgAlt+earthRadius,3)/GM))
newArr.push({name: p.name, orbitalPeriod: orbitalPeriod})
}
console.log(newArr)
return newArr;
}

orbitalPeriod([{name: “iss”, avgAlt: 413.6}, {name: “hubble”, avgAlt: 556.7}, {name: “moon”, avgAlt: 378632.553}]);


function orbitalPeriod(arr) {
  let newArr = []
  const GM = 398600.4418;
  const earthRadius = 6367.4447;
  for (let p of arr) {
    orbitalPeriod = Math.round(2*Math.PI*Math.sqrt(Math.pow(p.avgAlt+earthRadius,3)/GM))
    newArr.push({name: p.name, orbitalPeriod: orbitalPeriod})
  }
  console.log(newArr)
  return newArr;
}

orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0

Challenge Information:

Intermediate Algorithm Scripting - Map the Debris

Quotation marks are not an issue. Have you tried adding the second test case call (so they both are called)? At that point an error will appear in the console. See if that will give you enough hint as for what’s the problem.

orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]);
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
1 Like

THANK YOU BIG TIMES
YOU ARE GREAT! SO MUCH APPRECIATED! :pray: :pray: :pray: :pray: :handshake: :handshake: :handshake:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.