From cb77aaa6b6c58adfd0d8f7381a93b8ca67f1af9c Mon Sep 17 00:00:00 2001 From: Lucas Thenert Date: Fri, 27 Jan 2023 12:08:16 +0100 Subject: [PATCH] Funktion Full House implementiert --- kniffel/inc/fullHouse.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 kniffel/inc/fullHouse.js diff --git a/kniffel/inc/fullHouse.js b/kniffel/inc/fullHouse.js new file mode 100644 index 0000000..8491ce2 --- /dev/null +++ b/kniffel/inc/fullHouse.js @@ -0,0 +1,13 @@ +function fullHouse(wuerfelArr){ + + let countObj = {} + for(let x of wuerfelArr){ + countObj[x] = (countObj[x] || 0) + 1; + } + let vals = Object.values(countObj); + if((vals[0] === 2 && vals[1] === 3) || (vals[1] === 2 && vals[0] === 3)){ + return 25; + } + return 0; + +}