Created with <3 with dartpad.dev.
Created
November 7, 2023 01:50
-
-
Save leonus96/0791884348531353d155cf858aa1409a to your computer and use it in GitHub Desktop.
Ejercicio 3.1
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 reciba | |
/// una lista de números enteros y | |
/// devuelva la suma de todos los elementos. | |
// Imprime el resultado con interpolación de cadenas. | |
void main() { | |
final List<int> numeros = [23, 11, 3, 5, 12]; | |
print('La suma de los números es: ${sumaLista(numeros)}'); | |
} | |
int sumaLista(List<int> lista) { | |
int suma = 0; | |
for(int numero in lista) { | |
suma += numero; /// suma = suma + numero; | |
} | |
return suma; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment