Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getThrow(){
- let arr = [];
- for(let i = 0; i < 3; i++){
- arr.push(Math.floor((Math.random()*6) +1 ));
- }
- return arr;
- }
- let counter = 0;
- let pairCount = 0;
- while(true){
- let dice = getThrow();
- let validNumbers = true;
- for(let i = 0; i < dice.length; i++){
- if(dice[i] < 1 || dice[i] > 6){
- validNumbers = false;
- break;
- }
- }
- counter++;
- if(!validNumbers){
- pairCount = 0;
- continue;
- }
- if(dice[0] == 6 && dice[1] == 6 && dice[2] == 6){
- pairCount++;
- } else {
- pairCount = 0;
- }
- if(pairCount == 6){
- break;
- }
- }
- console.log(`Otne ${counter} opita da hvurlq 6 poredni zara s maksimalen broi!`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement