# Review Algorithmic Thinking by Building a Dice Game - Step 7

### Tell us what’s happening:

The code is producing the same results asked in the instructions. But still not getting passed. I don’t know where I’m making mistake. Anybody can help please?

``````<!-- file: index.html -->

``````
``````/* file: script.js */
// User Editable Region

const getHighestDuplicates = (array) => {
const counts = {};
score = 0;
array.forEach((num) => {
counts[num] = (counts[num] || 0) + 1;
});

const highest = Object.keys(counts).sort(
(a, b) => counts[b] - counts[a]
)[0];

console.log(highest);
console.log(counts[highest]);

if (counts[highest] >= 4) {
score = diceValuesArr.reduce((a, b) => a + b, 0);
return;
} else if (counts[highest] >= 3) {
score = diceValuesArr.reduce((a, b) => a + b, 0);
return;
} else {
}
}

if (rolls === 3) {
} else {
rolls++;
rollDice();
getHighestDuplicates(diceValuesArr);
}
});

// User Editable Region
``````
``````/* file: styles.css */

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36`

### Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

So I guess you are saying it works in the dice game itself but not passing. Are you using the console to check this, it might give you more informaiton.

I’m testing your code, for example calling `getHighestDuplicates([3,3,3, 5, 6])`, and always the score is 0

To calculate this, create a `getHighestDuplicates` function which takes an array of numbers.

You never use the function parameter

Can you please a bit elaborate? I mean, in the code, the method of generating the highest number is the issue.? Because consoling “highest” and counts[highest], produce the correct numbers and activates the correct radio buttons as well.

I consoled. It produce correct counts and also showing the correct number with highest count and enables radio button in the game.

instead of using the global value, you need to use the value passed to your function

here you have the parameter `array` , you use it only once, then to calculate the score you use `diceValuesArr`

never use `diceValuesArr` inside teh function

1 Like

Thanks very much . It worked.