Why does the last question in the array not show in the mapping function and also not taken into the score? (react/chart.js)

0👍

You have to remove that -1 in the code below.

  <div>
    {currentQuestion === questions.length ? ( // remove -1 from here
      <Radar
      data={chartData}
      options={{
      scale: {
        beginAtZero: true,
        max: 6,
        min: 0,
          ticks: {
              stepSize: 1,
          }
      }
    }}
  />

I don’t know what is Radar component but it seems you want to render it after all questions are shown. The currentQuestion starts with 0 so the condition must be n+1 with this logic that has been implemented.

Leave a comment