I’ve recently started checking the solutions on the hints page after solving a challenge to see how my solution compares to the ones provided. Is there any benefit to doing this for someone like me who is completely new to programming? The reason I ask is that I was super happy to have come up with the solution (I stole the Math.max method from a google search btw) but when I looked at the solutions provided on the hint page only 1 of the 4 made sense to me, while the other 3 flew right over my head.
While none of the solutions used the exact method I used, I got a little discouraged by my lack of understanding of the ones that were used. At this early stage, should I ignore the other methods and focus on what works for me, learning about the others later, or should I slow down and try to grasp the other concepts that are being used?
function largestOfFour(arr) {
let newArray = []
for (var i = 0; i < arr.length; i++) {
let arrValue = arr[i];
let highValue = 0;
highValue = Math.max(...arrValue)
newArray.push(highValue);
}
return newArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Return Largest Numbers in Arrays
Link to the challenge: