Review Algorithmic Thinking by Building a Dice Game - Step 7

Tell us what’s happening:

Is this step bugged? There seem to be a number of unresolved issues with this step on the forum. This is the 6th or 7th attempt I’ve made using different approaches that all work as intended in preview but somehow fail every test when submitted. This particular iteration also logs [TypeError: Reduce of empty array with no initial value] but I can’t replicate that outside of submitting and both instances of .reduce() have initial values.

Your code so far

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

/* file: styles.css */

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

const getHighestDuplicates = array => {
  const count = array.reduce((a,v)=>{
    a[v] ?  a[v] = a[v] + 1 : a[v] = 1;
    return a;
  }, {});
  const highest = Object.values(count).reduce((a,v)=>{
    if (v > a) {
      a = v
    };
    return a;
  }, 0);
  const sumDice = diceValuesArr.reduce((a,v)=>a+v);
  const lastOpt = scoreInputs.length - 1;
    updateRadioOption(lastOpt, 0);
  if (highest >= 4) {
    updateRadioOption(1, sumDice);
  } 
  if (highest >= 3) {
    updateRadioOption(0, sumDice);
  }    
  return;
};

rollDiceBtn.addEventListener("click", () => {
  if (rolls === 3) {
    alert("You have made three rolls this round. Please select a score.");
  } else {
    rolls++;
    rollDice();
    updateStats();
    getHighestDuplicates(diceValuesArr);
  }
});

// User Editable Region

Your browser information:

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

Challenge Information:

Review Algorithmic Thinking by Building a Dice Game - Step 7

the error is from here, diceValuesArr does not always have a value, and you should not use it inside the function. Remember it has a parameter

AHHHHH Thank you so much it was such a simple fix. Lesson learned.

The step in question does appear to be bugged or at least poorly documented, based on the user’s experience and reports from others on the forum. Despite multiple attempts using various approaches that function correctly in preview mode, the solutions consistently fail when submitted.