Skip to content

Commit 880b9d5

Browse files
author
codingChewie
committed
Randomize Cards
1 parent 4739069 commit 880b9d5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

routes/cards.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ router.get('/:id', (req, res) => {
1212
const text = cards[id][side]
1313
const { hint } = cards[id]
1414

15-
const templateData = { text }
16-
if (side === 'question') templateData.hint = hint
15+
const templateData = { id, text }
16+
17+
if (side === 'question') {
18+
templateData.hint = hint
19+
templateData.sideToShow = 'answer'
20+
}
21+
22+
if (side === 'answer') templateData.sideToShow = 'question'
23+
1724
res.render('card', templateData)
1825
})
1926

views/card.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ block content
66
if hint
77
p
88
i Hint: #{hint}
9-
9+
a(href=`/cards/${id}?side=${sideToShow}`)= `${sideToShow.charAt(0).toUpperCase()}${sideToShow.slice(1)}`

0 commit comments

Comments
 (0)