I got stuck again what am i doin wrog

i got stuck again can you helpTell us what’s happening:
Describe your issue in detail here.

  **Your code so far**



const defaultState = {
authenticated: false
};

const authReducer = (state = defaultState, action) => {

switch (action.type) {
  case 'LOGIN': 
    return {
      authenticated: true
    }
  case 'LOGOUT': 
    return {
      authenticated: false
    }

  default:
    return state;

}

};

const store = Redux.createStore(authReducer);

const loginUser = () => {
return {
  type: 'LOGIN'
}
};

const logoutUser = () => {
return {
  type: 'LOGOUT'
}
};
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36

Challenge: Use const for Action Types

Link to the challenge:

i got stuck again what am i doin wrog

Hi @freshoso !

The first step is to declare LOGIN and LOGOUT as const values and assign them to the strings 'LOGIN' and 'LOGOUT' .

I don’t see those variable declarations in your code anywhere.

Once you create those two variables then you need to use them here

i dont understand were tho an it confusing

Let’s just focus on the first part.

We need to create two const variables called LOGIN and LOGOUT .
And you need to assign to them the strings 'LOGIN' and 'LOGOUT'.

Try to create those two lines of code and then we can focus on the second part.


ADD YOUR TWO VARIABLES HERE
const defaultState = {
  authenticated: false
};

const authReducer = (state = defaultState, action) => {

  switch (action.type) {
    case 'LOGIN': 
      return {
        authenticated: true
      }
    case 'LOGOUT': 
      return {
        authenticated: false
      }

    default:
      return state;

  }

};

const store = Redux.createStore(authReducer);

const loginUser = () => {
  return {
    type: 'LOGIN'
  }
};

const logoutUser = () => {
  return {
    type: 'LOGOUT'
  }
};

okay i will let you knw wen im done

1 Like

okay i got dat done whats next

Ok cool.

Now you need to use those variables names in these areas instead of the strings.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.