Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Marcus Thelin
1,188 PointsWhere did we get the index value from?
For example when we do the
toggleConfirmationAt = indexToChange => {
this.setState({
guests: this.state.guests.map((guest, index) => {
if(index === indexToChange) {
return {
...guest,
isConfirmed: !guest.isConfirmed
}
}
return guest;
})
})
}
1 Answer

Steven Parker
228,025 PointsThe map method supplies both the current item and it's index as arguments to the callback.
Marcus Thelin
1,188 PointsMarcus Thelin
1,188 PointsThank you so much! I have totally missed that. Here's a reference to the ppl with the same questions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Steven Parker
228,025 PointsSteven Parker
228,025 PointsOr you can click on the blue word "map" in my answer.