Created with <3 with dartpad.dev.
Created
October 24, 2023 03:02
-
-
Save leonus96/e78f7092657d1c6df6bcbb82a47a5aa3 to your computer and use it in GitHub Desktop.
cadena-larga
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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