[spoiler]
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
var newArr = []; //gives me a empty array
for (var i = 0; i < arr.lenght; i++) {
var results =
Math.round(2*Math.PI*Math.sqrt(Math.pow(earthRadius+arr[i].avgAlt,3) / GM));
newArr.push({name: arr[i].name, orbitalPeriod: results }); //Loops number times in the array and computes the eqution.
}
return newArr;
}
orbitalPeriod([{ name: "sputnik", avgAlt: 35873.5553 }]);
[/spoiler]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0.
In regards to the title of the post, that You’re not cut for this, don’t give up .
This challenge, IMHO, is not a good one. It’s really easy to solve if we didn’t have to understand astrophysics (or orbital physics).
Of course, You may happen to be an astrophysicist, and it may help you develop your research skills, but for most of the people (including me) is just something outside of their area of study.
This is IMHO and, of course, I might be missing something .
For what it is worth, I think the fact that your solution has no unnecessary data mutation makes it better than all the solutions given in the hints.
I would suggest using a coding environment that can help you catch mistakes. I would use VS Code and some good extensions. Like, Quokka for live code eval, Prettier for formating, Code Spell Checker to catch typos and maybe Bracket Pair Colorizer to help with code block matching.
Break it down into smaller pieces. To start off, log every line to the console so that you can see what the result of a statement is. Only when you are sure any piece of code evaluates to then start putting it together. Form a deep relationship with the console and the compiler. It will be your best friend to create your program.
It feels to me like it was done to throw a problem at the student which would require “research”. Which in of itself isn’t necessarily a bad thing.
It’s just that any important programming concepts this challenge might have taught get a bit lost in the pretty obscure math problem that overshadows the challenge.
@camperextraordinaire console.log() isn’t working for me in freeCodeCamp editor. I don’t see the log. Quokka puts right in the code so it can be seen. If I can get it to work. I’m working on this one now… JavaScript Algorithms and Data Structures Projects: Cash Register