Browse Source

Funktion Dreierpasch erstellt

main
Lucas Thenert 2 years ago
parent
commit
ca7b2ad5d9
  1. 15
      kniffel/inc/dreierPasch.js
  2. 1
      kniffel/index.html

15
kniffel/inc/dreierPasch.js

@ -0,0 +1,15 @@
function dreierPasch(wuerfelArr){
let output = 0;
let countObj = {}
for(let x of wuerfelArr){
countObj[x] = (countObj[x] || 0) + 1;
}
let vals = Object.values(countObj);
if(( vals[1] === 3) || (vals[0] === 3)|| (vals[2] === 3)){
wuerfelArr.forEach(element => {
output += element;
});
}
return output;
}

1
kniffel/index.html

@ -7,6 +7,7 @@
<script type="text/javascript" src="inc/sammleGleicheZahlen.js"></script>
<script type="text/javascript" src="inc/helper.js"></script>
<script type="text/javascript" src="inc/summeObererTeil.js"></script>
<title>Kniffel</title>
</head>
<body>

Loading…
Cancel
Save