Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolución ejercicio 1 equipo 5 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Ejercicio.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>

<script src="ejercicio_1.js"></script>
<script>
//var partida_dardos = ( [1, 5, 11] );// => 15
//var partida_dardos = ( [15, 20, 30] );// => 0
//var partida_dardos = ( [1, 2, 3, 4] );// => 140
var partida_dardos = ([]);// => 0
alert(Resultado(partida_dardos));
</script>

</html>
20 changes: 20 additions & 0 deletions ejercicio_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,23 @@ partida_dardos([]) => 0

** IMPORTANTE: Antes de escribir su código, cree un branch con su nombre o el de su equipo. Luego deberá subir al repositorio su resolución!
*/
function Resultado(Arreglo){
if(Arreglo.length == 0 || Arreglo == null){
return 0;
}

var Resultado = 0;
var PremioMayor = 0;
for(var Indice = 0; Indice < Arreglo.length; Indice ++){
if(Arreglo[Indice] < 5){
Resultado += 10;
PremioMayor ++;
}else{
if(Arreglo[Indice] <= 10){
Resultado += 5;
}
}
}

return Resultado + (PremioMayor == Arreglo.length ? 100 : 0);
}