Handle an Action in the Store Issue

Tell us what’s happening:
Hello world!
I’m having an issue where I’m completely stuck.
The tests say that my code isn’t updating the state at the right time, nor is it initialising the state to login: false.
Any help will be appreciated!
Your code so far

const defaultState = {
  login: false

const reducer = (state = defaultState, action) => {
  // change code below this line
  if (action.type = "LOGIN"){
    console.log(Object.assign({}, state, {
        login: true
      }), state )
    return Object.assign({}, state, {
        login: true

  console.log("Keeping the old state of ", state)
  return state
  // change code above this line

const store = Redux.createStore(reducer);

const loginAction = () => {
  return {
    type: 'LOGIN'

Your browser information:

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

Link to the challenge:

No need to complicate this!

First error I see is your if statement. Are you comparing or assigning a value?

Then if your if statement is true, then simply return an object where login is true else return state.

1 Like

I feel like a complete and total idiot. I made the oldest mistake in the book, mixing up a comparison and a declaration.
Once I fixed that, it was fine.