Working through the algorithm scripting to create an array only with the largest numbers out of an array with subarrays. My code thus far below - appreciate any feedback/advise on whether my codes can work or not for the problem statement!
Hey @jaydenkeh ! You are super close. Great use of the spread operator to find the max number in that array index. Consider the use of something that can iterate through the rest of the array because as it stands the code is missing a few instructions that will allow you to return the solution you want!
Any additional questions or want more tips then let me know
don’t forget this given suggestion: Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i].
but inside that you could break down the code into different lines for each step and console.log results to see what is happening.
e.g.
Mi recomendation is you should take a break and back later to this challenge or even tomorrow. You will expend less time solving challenges if you give your brain time to figure out. You always can jump to the next challenge or do a different thing.
Anyway you are close to solve it and he is my hint : notice that you have a array of subarrays, and you need to find max number in every subarray. I think that for loops are beautiful this time of year.
Hey @jaydenkeh Thank you for your patience well as it stands, your pushing to …arr. Make sure you check out the syntax for .push here and make sure you’re pushing the highest number to the right array i.e. largestNumberArray.
In terms of the subarray that you’re accessing, think back to how we access arrays. These subarrays could be considered as elements like we access elements in a standard array. e.g.
arrElementExample = [6,3,7,8,11,65,12]
We can use Array indexing to access the following numbers with some examples below
arrElementExample[2]; // 7
arrElementExample[4]; //11
The same can be said for your array. Think of these subarrays in a similar way to the arrElementExample