Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
449 B
4
Indexable
Never
const array = [
  "Ana Paula",
  "Alvaro",
  "Jesus",
  "Steve",
  "Antonio",
  "Mega Ultra Jesus",
];

function longestStudent(array) {
    
  let longestName = "";

  for (let index = 0; index < array.length; index++) {
    console.log(array[index]);
    if (array[index].length > longestName.length) {
      longestName = array[index];
    }
  }
  console.log("Nombre más largo: ", longestName);
}

longestStudent(array);