In the "Showing the Past Moves" section here, we have the below code:
const moves = history.map((step, move) => {
const desc = move ?
'Go to move #' + move :
'Go to game start';
return (
<li>
<button onClick={() => this.jumpTo(move)}>{desc}</button>
</li>
);
});
This code seems to be first mapping a built in variable "step" to variable "move", before essentially having this Python logic:
const moves = [lambda move: const desc = move ... for move in history]
As someone who is familiar with Python but not javascript, can you explain:
1) "step" variable is not assigned anywhere, and I haven't been able to google a built in step variable, so how is "step" getting assigned to the number of game moves?
2) What is the logic behind this syntax: (step, move) meaning first map step into move, then execute a lambda function? Primarily, the first 'map step into move' part doesn't make sense to me.