Can the following function (which is inside a class) be shortened:
getCurrentMoves(moves = this.state.moves, stepNumber = this.state.stepNumber) {
return moves.slice(0, stepNumber);
}
All I managed to do is to refactor it to the following. However, this refactor changed the number of parameters from 2 to 1:
getCurrentMoves({moves, stepNumber} = this.state) {
return moves.slice(0, stepNumber);
}
Is there a way to keep it 2 parameters and use default parameter syntax, as well as destructuring syntax in order to avoid code duplication?