`;
grid.appendChild(card);
});
}
function highlight(sentence, verb) {
const regex = new RegExp(`\\b(${verb})\\b`, 'gi');
return sentence.replace(regex, `$1`);
}
function filterBy(cat) {
currentFilter = cat;
document.querySelectorAll('.cat-btn').forEach(b => b.classList.remove('btn-active'));
event.target.classList.add('btn-active');
update();
}
function update() {
const query = searchInput.value.toLowerCase().trim();
filteredVerbs = verbData.filter(v => {
const searchStr = `${v.v1} ${v.v1_bn}`.toLowerCase();
const matchSearch = searchStr.includes(query);
const matchCat = currentFilter === 'All' || v.cat === currentFilter;
return matchSearch && matchCat;
});
renderVerbs();
}
searchInput.addEventListener('input', update);
// Quiz Logic
let quiz = { q: [], i: 0, s: 0 };
function startQuiz() {
quiz.q = [...verbData].sort(() => Math.random() - 0.5).slice(0, 10);
quiz.i = 0; quiz.s = 0;
renderQ();
document.getElementById('quiz-section').scrollIntoView({ behavior: 'smooth' });
}
function renderQ() {
const current = quiz.q[quiz.i];
const type = Math.random() > 0.5 ? 'v2' : 'v3';
const answer = current[type];
let options = [answer];
while(options.length < 4) {
const r = verbData[Math.floor(Math.random() * verbData.length)][type];
if(!options.includes(r)) options.push(r);
}
options.sort(() => Math.random() - 0.5);
document.getElementById('quiz-box').innerHTML = `
What is the ${type === 'v2' ? 'PAST' : 'PARTICIPLE'} form of
`;
}
function check(sel, ans) {
if(sel === ans) quiz.s++;
quiz.i++;
if(quiz.i < 10) renderQ();
else finish();
}
function finish() {
document.getElementById('quiz-box').innerHTML = `
`;
}
window.onload = renderVerbs;
Question ${quiz.i+1}/10Score: ${quiz.s}
What is the ${type === 'v2' ? 'PAST' : 'PARTICIPLE'} form of
"${current.v1}"?
${options.map(o => ``).join('')}
🏆
কুইজ শেষ!
আপনি ১০ এর মধ্যে ${quiz.s} পেয়েছেন।