-1

So, I am working on a wheel of fortune. I have a const list with a lot of questions. Underneath the const list is a randomizer that picks a random question.

The thing is that on the wheel of fortune segments it displays the random question but I want to show the const name.

After it stops spinning it indicates the segment and make an alert with the question.

const questioncard = ['question1','question2','question3']
const randomquestioncard = questioncard[Math.floor(questioncard.length * Math.random())];
Renaldo
  • 1
  • 1
  • 3
    You can't refer to variable names in JS. – Teemu Jan 18 '23 at 09:33
  • Maybe you know a workaround? – Renaldo Jan 18 '23 at 09:34
  • There's no workaround, what is not implemented in the engine, is simply not possible. Your question is a bit ambiguous, though, what variable name you want to show, in the question there doesn't seem to be anything related to the title. – Teemu Jan 18 '23 at 09:36

1 Answers1

0

Why don't you keep the data like this:

[{question:'question1', text:'text of the question 1'},{question:'question2', text:'text of the question 2'},{question:'question3', text:'text of the question 2'}]
Cristian Riță
  • 561
  • 3
  • 13