Skip to content

Commit 6385555

Browse files
committed
refactor: includes instead of index of
1 parent 1eeb46c commit 6385555

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

components/mdx/Question.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const Question: FC<QuestionProps> = (props: QuestionProps) => {
2424
const toast = useToast()
2525

2626
const selectAnswer = (optionIndex: number) => {
27-
if (optionsSelected.indexOf(optionIndex) !== -1) {
27+
if (optionsSelected.includes(optionIndex)) {
2828
return setOptionsSelected(
2929
optionsSelected.filter((o) => o !== optionIndex),
3030
)
@@ -36,7 +36,7 @@ const Question: FC<QuestionProps> = (props: QuestionProps) => {
3636
}
3737

3838
const getOptionBackground = (optionIndex: number) => {
39-
if (optionsSelected.indexOf(optionIndex) !== -1) {
39+
if (optionsSelected.includes(optionIndex)) {
4040
return 'yellow.600'
4141
}
4242
return 'gray.600'
@@ -73,7 +73,7 @@ const Question: FC<QuestionProps> = (props: QuestionProps) => {
7373
}
7474

7575
const submit = () => {
76-
if (optionsSelected.indexOf(-1) !== -1) {
76+
if (optionsSelected.includes(-1)) {
7777
return quizNotAnswered()
7878
}
7979

0 commit comments

Comments
 (0)