MCPcopy
hub / github.com/midudev/preguntas-entrevista-react / prepareAlternatives

Function prepareAlternatives

app/components/Quiz.jsx:89–98  ·  view source on GitHub ↗
(full = [])

Source from the content-addressed store, hash-verified

87 }
88
89 function prepareAlternatives(full = []) {
90 if (!Array.isArray(full) || full.length === 0) return []
91 const correct = full.find(a => a.is_correct) || full[0]
92 const incorrect = full.filter(a => a !== correct)
93 const shuffledIncorrect = [...incorrect].sort(() => Math.random() - 0.5)
94 const needed = Math.max(0, 5 - 1)
95 const pickedIncorrect = shuffledIncorrect.slice(0, needed)
96 const subset = [correct, ...pickedIncorrect]
97 return subset.sort(() => Math.random() - 0.5)
98 }
99
100 if (status === 'loading') {
101 return (

Callers 2

QuizFunction · 0.85
handleRestartFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected