You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
409 B

  1. function dreierPasch(wuerfelArr){
  2. let output = 0;
  3. let countObj = {}
  4. for(let x of wuerfelArr){
  5. countObj[x] = (countObj[x] || 0) + 1;
  6. }
  7. let vals = Object.values(countObj);
  8. if(( vals[1] === 3) || (vals[0] === 3)|| (vals[2] === 3)){
  9. wuerfelArr.forEach(element => {
  10. output += element;
  11. });
  12. }
  13. return output;
  14. }
  15. module.exports = dreierPasch;