Respuestas Ejercicio 50 (JS Julio)

Comparte tu respuesta del ejercicio 50.

const max = (arr) => Math.max(...arr)

const max = arrNums => arrNums.reduce((a, b) => Math.max(a, b));

respuesta:

const max = myArray => myArray.reduce((accum, item) => accum > item ? accum : item, undefined);
const max = arr => arr.reduce((a, b) => a > b ? a : b);
const max = (arr) => {
  let max = arr[0]
  for (let i of arr){
    if(i > max) max=i
  }
  return max
}

Buenas noches esta es mi solución:

const max = (arr)=>{
  let aux = arr[0];
  for(let i of arr){
    if(i>aux){
      aux=i
    }
  }
  return aux;
}
const max = arr => arr.reduce((a, b) => a > b ? a : b);


console.log(max([1, 2, 3, 4]))
console.log(max([63, 85, 39, 24, 3]))
const max = arr => arr.sort( (a, b) => a - b )[arr.length-1]
const max = arr => arr.reduce((a, b) => (a > b ? a : b));
const max=(arr)=>{
  let aux=arr[0];
   arr.splice(1).map(el=>el>=aux ? aux=el: aux)
   return aux;
  
}
console.log(max([1, 2, 3, 4])) // 4
console.log(max([63, 85, 39, 24, 3])) // 85
const max = (arreglo) =>  {
  let max = arreglo[0]
  for (let i of arreglo){
    if(i > max) max=i
  }
  return max
}

// código de prueba
console.log(max([1, 2, 3, 4])) // 4
console.log(max([63, 85, 39, 24, 3])) // 85

Respuesta ejercicio 50:

// Ejercicio 50
const max = (arreglo) => {
  const [first, ...array] = arreglo
  let maximo = first
  for(val of array){
    if (maximo < val )
      maximo = val
  }
  return maximo
}
const max = arrNumbers => arrNumbers.reduce((a,b) =>  a>b?a:b)

Buenas tardes
esta es mi respuesta

const max = arr => arr.reduce((mayor,num)=>num>mayor?num:mayor)
// escribe tu solución acá
const max = (nums) => {
  //console.log(nums)
  let theMax = nums[0];
  for (let i = 1; i <= nums.length; i += 1) {
    if (nums[i] > theMax) {
      theMax = nums[i];
    }
  }
  return theMax;
};



const max =(nums=[])=>{
  let m=nums[0]
  for(let i of nums)
    if(i>m)
      m=i
  return m
}
const max=(arr)=>{
  let aux=arr[0];
   arr.splice(1).map(el=>el>=aux ? aux=el: aux)
   return aux;
}

const max = arr => arr.reduce((aux1, aux2) => aux1 > aux2 ? aux1 : aux2)

const max = (arra) =>  arra.reduce((max, current) => (current > max ? current : max));