I need to assign assign each input their own id.
const sep = words.map((word, ind) => {
return (
<div key={ind} className="guess__word">
{word.split("").map((letter, id) => {
if (letter === " ") {
return <SpaceBox key={id} letter={letter} />;
} else {
return <LetterBox key={id} id={id} letter={letter} />;
}
})}
</div>
);
});
The problem that I am having is that due to the map being nested, the value of id keeps reseting back to 0. Each word of words has a different length so if kinda hard to figure out if there is a math equation that would help me solve this.
for reference, the length of each word is 10, 3, 4, and 4.
Also I need the ids to equal up to the length of words. So I would need the ids to be 0-20.