Update on JavaScript Progress Question

Hey Everyone!

So, I commented a couple of days ago that I was having some issues solving the Basic and Intermediate Algorithm questions. I went back and covered some information on array manipulation, loops, etc… I think I am grasping it, and instead of clicking for hints, I am spending a little more time getting creative as well as using mdn docs. With that being said here is my question. Previously I was worried about having an answer that would be accepted (example: shortest code, preferred method, etc…). But with getting more creative I don’t know if I am off the depend end with my answers or not.

Here is an example of what I mean using the Basic Algorithm Scripting: Return Largest Numbers in Arrays question.

This is what I have, and it works!

function largestOfFour(arr) {
  var newArray = [];

  for (var i = 0; i < arr.length; i++) {
    var array = arr[i];
  return newArray;

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

But this answer is not even one of the three levels when you click get a hint. Should I not be so creative, or is it more of a “Great Job, You didn’t look at the answers!!!”

Just want to make sure I have the right frame of reference for this!

Thanks for any feedback!

I would be very skeptic when looking at the “levels” of the hints. Sometimes those hints are not even up to date.

Regarding your solution, it’s fine. Of course one can nitpick that you don’t have to declare a variable if you only use it once on the next line, or that you could use .forEach instead of for loop (or even .map() and write a one-liner).

1 Like