After experimenting with different methods, I noticed that when using
(age => age.Book === book && age.Chapter === 1)
as my filter criteria, everything works perfectly.
However, when I try using
(age => age.Book === book && age.Chapter === chapter)
, the filter does not work as expected.
I found that if I use a hardcoded number or string for 'chapter', rather than a variable, it works just fine. But once I introduce a variable for 'chapter', things stop working.
All of my chapters are represented by numbers. Interestingly, changing one chapter to a string (a word instead of a number) caused my 'chapter' variable to start working.
Can anyone shed some light on how I can make my 'chapter' variable function properly?
app.get("/book/:bookTitle/:bookChapter/", function(req, res){
const book = req.params.bookTitle;
const chapter = req.params.bookChapter;
const verse = req.params.bookVerse;
const text = req.params.bookText;
const getBook = verseList.filter(age => age.Book === book && age.Chapter === 1);
const getBook = verseList.filter(age => age.Book === book && age.Chapter === chapter);