Skip to content

Instantly share code, notes, and snippets.

@leonus96
Created October 24, 2023 03:02
Show Gist options
  • Save leonus96/e78f7092657d1c6df6bcbb82a47a5aa3 to your computer and use it in GitHub Desktop.
Save leonus96/e78f7092657d1c6df6bcbb82a47a5aa3 to your computer and use it in GitHub Desktop.
cadena-larga
/// Implementa una función que tome una
/// lista de nombres y devuelva el nombre
/// más largo.
void main() {
final List<String> nombres = [
'EDDIE',
'CARLOS FARRO',
'KATERIN',
'JOSEPH',
];
print(elMasLargo(nombres));
}
String elMasLargo(List<String> nombres) {
String largo = ''; //CARLOS FARRO
for(int i = 0; i < nombres.length; i++) {
if(nombres[i].length > largo.length) {
largo = nombres[i];
}
}
return largo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment