Skip to content
Prev Previous commit
Next Next commit
created a seperate function to generate ramdom question Id.
  • Loading branch information
Shashank5665 committed Aug 21, 2022
commit 05a0559fe40c4529a1d77b75ca02ef1190b1e98a
15 changes: 7 additions & 8 deletions src/components/Table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,20 @@ const Table = () => {
},
{
Header: () => {
const randomQuestion = () => {
const random = Math.floor(Math.random() * questions.length);
const questionId = questions[random].id;
const questionSlug = questions[questionId].url;
window.open(`${questionSlug}`, '_blank');
};
return (
<>
<div
style={{ whiteSpace: 'nowrap', display: 'inline-block' }}
>
Questions{' '}
<Button
onClick={() => {
const random = Math.floor(
Math.random() * questions.length,
);
const questionId = questions[random].id;
const questionSlug = questions[questionId].url;
window.open(`${questionSlug}`, '_blank');
}}
onClick={randomQuestion}
color="dark"
id="random-question-button"
size="sm"
Expand Down