Basic algorithm scripting.Please show me where i was wrong

This should return an array of maximum elements from arrays:

function largestOfFour(arr) {

  function max_value(array){
    // find max value in array
    let value=array[0];
    for(let i=0;i<array.length-1;i++){
    return value;
let new_array=[];
for(let index=0;index<arr.length-1;index++){
  let b=arr[index];
  let a=max_value(b);
  return new_array;

you assign the element at index 0 to a variable but then start the loop at index 0 anyway
then you run the loop only untill i < array.length - 1 - what has the last item done to you? (this same thing on the other loop)

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Thank You! About length - 1 I did not think.