Redux Road Project

Hello world, I have a problem with the Redux Road project. Basically, I wrote all the code by following the instruction given, but I have a different output.

Link to the project: https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-redux/modules/core-concepts-in-redux/projects/redux-road-core-concepts

On task 11 of Redux Road, I am stuck. The value that I get is different from the instruction given which needs:

{
  supplies: 5,
  distance: 40,
  days: 6
}

This is my code →

And the output that I got from my code:

{ supplies: 100, distance: 0, days: 0 }
{ supplies: 80, distance: 10, days: 1 }
{ supplies: 95, distance: 10, days: 2 }
{ supplies: 65, distance: 10, days: 3 }
{ supplies: 45, distance: 20, days: 6 }

task 5 says:

  • 20 less supplies for each day
  • 10 more kilometers of distance traveled for each day

which means on your code

case “travel”: {
return {
…state,
supplies: state.supplies - 20,
distance: state.distance + 10,
days: state.days + action.payload,
}
}

you need to include that 'each day ’

I did :

case “travel”: {
return {
…state,
supplies: state.supplies - 20action.payload,
distance: state.distance + 10
action.payload,
days: state.days + action.payload,
}
}

(sorry I realised Codecademy removed (*) between 10 and action.payload :slight_smile:

hope this helps :slight_smile:

1 Like

Thank you so much :smiling_face_with_three_hearts:, my first solution to this was adding a conditional statement on case "travel" lmao.

1 Like