My problem is that I cannot seem to modify the variable that the pug file uses to loop.
section.p-0.md-p-5.muli
.flex.flex-wrap
script.
var users2 = '#{users}';
console.log(users2);
/*
const searchBar = document.getElementById('searchBar');
searchBar.addEventListener('keyup', (e) => {
const search = e.target.value;
const filteredFiles = users2[0].filter(user => {
return user.toString[0][0].includes(search);
})
console.log(filteredFiles);
});
*/
each user in users2
.w-100pc.md-w-33pc.p-10
a.block.no-underline.p-5.br-8.hover-bg-indigo-lightest-10.hover-scale-up-1.ease-300.filePage(href=`/${user.slug}`)
img.w-100pc(src=`${user.photoUrl[0]}` alt='')
p.fw-600.white.fs-m3.mt-3
| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed…
.indigo.fs-s3.italic.after-arrow-right.my-4 3 days ago by Jeff
In the 3 line I have a script tag that sets a passed in array of objects. Than I want to modify those objects and pass the new filtered array to loop on line 16. However, I do not know how to pass the variable from line 4 to line 16. When I run the code I get the error "Cannot read property 'length' of undefined". Any ideas on how to fix this? Thanks.