Redux Road

Hello, i got stuck on the Redux Road project

Task No12:
Currently, the player can continue traveling even if their supplies are negative! Fix this in the 'travel' case.
If there are not sufficient supplies to travel the given number of days, return the current state.

I can’t figure out how to bind this in the case:

case “travel” : {
return {

    supplies: -20,
    distance: state.distance +10,
    days: state.days+1

Hello, and welcome to the forums!

You can approach this using a regular if/else if you want. The state object gives you access to the existing properties / values, so you can use to see how many supplies are on hand. The action object includes the payload property, which represents the number of days being attempted to travel. You can calculate how many supplies are required to travel that many days, then compare it to the existing supplies on hand. If there aren’t enough, just return the existing state without changes.

Also, if the code you posted is what you have currently for the travel action type, then you should revisit Step #5 of the project. Instead of hardcoding the values used to recalculate, you should be using the action.payload as part of the calculation since it represents how many more days are traveled.