JSFiddle - React, Tailwind, and code Playground
by jonahe
JavaScript
const correctIndexes = [0,3];
const maxCorrect = correctIndexes.length;
const selectedIndexes = [0,1,3];
const newArray = [0,3,0,1,3];
const correctIndex = 3;
function countCorrect(correctIndexes, selectedIndexes) {
return selectedIndexes.filter(ind => correctIndexes.includes(ind)).length;
}
console.log(countCorrect(correctIndexes,selectedIndexes))