Skip to content

Commit

Permalink
Merge pull request #4 from bokuanT/master
Browse files Browse the repository at this point in the history
Add a check that rejects duplicate question titles on submission
  • Loading branch information
bokuanT authored Sep 11, 2023
2 parents e2b24b8 + 333d752 commit 2eddadd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ document.addEventListener('DOMContentLoaded', function() {
// Get question title
var questionTitle = document.getElementById('questionTitle').value;

// Check that question title is not a duplicate, even if case is different
const duplicateQuestion = questions.find(q => q.title.toLowerCase() === questionTitle.toLowerCase());
if (duplicateQuestion !== undefined) {
alert('Question title already exists');
return;
}

// Get question category
var questionCategory = document.getElementById('questionCategory').value;

Expand Down

0 comments on commit 2eddadd

Please sign in to comment.