Skip to content

Commit

Permalink
resolución juego de dardos
Browse files Browse the repository at this point in the history
  • Loading branch information
jotero committed Dec 3, 2020
1 parent a6c5f59 commit f7faf75
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions juegoDardos.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function partida_dardos(radios) {
let total = 0,
todosMenores = true,
tieneValores = false;
radios.forEach((tiro) => {
tieneValores = true;
if (tiro > 10) {
todosMenores = false;
} else {
if (tiro >= 5 && tiro <= 10) {
total = total + 5;
todosMenores = false;
} else {
total = total + 10;
}
}
});
if (todosMenores && tieneValores) {
total = total + 100;
}
return total;
}

//prueba tiros
console.log(partida_dardos([1, 5, 11]));
console.log(partida_dardos([15, 20, 30]));
console.log(partida_dardos([1, 2, 3, 4]));
console.log(partida_dardos([]));

0 comments on commit f7faf75

Please sign in to comment.