Where is the answer?

Now I am doing the redux road project, but I have something don’t understand. So i want to check the answer to know about it.

there are not the view solution button for me to click

Hi there, welcome to the community.

From memory, many of the “project” type activities from the catalog don’t come with solutions that you can check. There are hints for each of the steps, but the projects themselves are meant to challenge you to apply the material from the course so far with less assistance than you would get from a lesson.

In the case of Redux Road, it looks like there isn’t a walkthrough video available either (which there is for some other projects).

If you let us know what it is that you’re stuck with, we may be able to help you out. :slight_smile:

1 Like

my code is that
I don’t know what I should type in each of the payload.

const initialWagonState = [
supplies:100,
distance : 0,
days:0
];

const gather ={
type:“gather”,
payload:
}

const travel ={
type:“travel”,
payload:
}

const tippedWagon ={
type:“tippedWagon”,
payload:
}

function empty (state=initialWagonState,action){
switch(action.type){

case “gather” :{
return {
…state,
supplies: state.supplies+15,
days:state.days+1
};
}
case “travel”:{
return {
supplies: state.supplies-(20*days),
distance: state.distance+(days+10),
days:state.days+days
};
}
case “tippedWagon”:{
return{
…state,
supplies: state.supplies-30,
days:state.days+1
};
}

default:{
return state;
}
}

let wagon = empty({});
console.log(wagon);

Did you try going back and reading the directions thoroughly? Sometimes I accidentally skip over important things when skimming through directions.

The action types ‘gather’ and ‘tippedWagon’ don’t have payloads. The project instructions mention what needs to be done to the supplies and days properties of the state if either of those happen, but it isn’t reliant on an extra piece of data for the calculation.

The action type ‘travel’ does have a payload that is a number representing the number of days. Right now your reducer is using a variable named days where it should be using the action.payload

Also, this isn’t related to your payload question, but make sure you revisit Step 7 because you haven’t done exactly what this step says so it will lead to problems.

1 Like

How to do the step 7 ? I tried different code, just does not work. I don’t understand how to play the game

let myState = reducer(undefined, {});
myState = reducer(myState, ‘gather’);

myState = reducer(myState, ‘gather’);

console.log(myState)

I’ve done it like this and it worked .

let wagon = reducer(undefined, {});
console.log(wagon);

I’m struggling from the step 8 onwards