Chorebot Project help

Hi please help - when I add the randomChoreDoorGenerator arrow function the arrow (>) turns red along with the rest of the arrows in the code below. I do not know why this is happening and I have restarted the projected in hopes that it would fix this but it hasn’t. Thank you!

let doorImage1 = document.getElementById(‘door1’);
let doorImage2 = document.getElementById(‘door2’);
let doorImage3 = document.getElementById(‘door3’);
let botDoorPath = ‘https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg
let beachDoorPath = ‘https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/beach.svg
let spaceDoorPath = ‘https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/space.svg

const numClosedDoors = 3;
let openDoor1 =;
let openDoor2 =;
let openDoor3 =;

//why does the arrow here and below turn red and my code stop working. I was able to access the doors before I added this function. When I try the code in visual studio code I do not see an issue with the arrow function.

const randomChoreDoorGenerator () =>{
const choreDoor = Math.floor(Math.random() * numClosedDoors);
if(choreDoor === 1){
openDoor1 = botDoorPath;
openDoor2 = beachDoorPath;
openDoor3 = spaceDoorPath;
} else if (choreDoor === 2{
openDoor1 = beachDoorPath;
openDoor2 = spaceDoorPath;
openDoor3 = botDoorPath;
} else {
openDoor1 = spaceDoorPath;
openDoor2 = botDoorPath;
openDoor3 = beachDoorPath;
}
}

doorImage1.onclick = () =>{
doorImage1.src = openDoor1;
}

doorImage2.onclick = () =>{
doorImage2.src = openDoor2;
}

doorImage3.onclick = () =>{
doorImage3.src = openDoor3;
}

1 Like

Please don’t forget to press the image when posting code and put the code into the three signs that should appear.

The problem is that you didn’t put a = sign after const randomChoreDoorGenerator and simply put the arrow function after.
The correct syntax would be:

const arrowFunctionSyntax = (parameter1, parameter2) => {
  console.log(parameter1 + parameter2);
}

Thanks for the response - I did not know about the </> function when using this so thank you for that as well.

Even when I do have the = in the arrow function the same error is occuring

let doorImage1 = document.getElementById('door1');
let doorImage2 = document.getElementById('door2');
let doorImage3 = document.getElementById('door3');
let botDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/robot.svg'
let beachDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/beach.svg'
let spaceDoorPath = 'https://s3.amazonaws.com/codecademy-content/projects/chore-door/images/space.svg'

const numClosedDoors = 3;
let openDoor1 =;
let openDoor2 =;
let openDoor3 =;

//why does the arrow here and below turn red and my code stop working. I was able to access the doors before I added this function. 

const randomChoreDoorGenerator = () =>{
 const choreDoor = Math.floor(Math.random() * numClosedDoors);
  if(choreDoor === 1){
    openDoor1 = botDoorPath;
    openDoor2 = beachDoorPath;
    openDoor3 = spaceDoorPath;
  } else if (choreDoor === 2{
    openDoor1 = beachDoorPath;
    openDoor2 = spaceDoorPath;
    openDoor3 = botDoorPath;
  } else {
    openDoor1 = spaceDoorPath;
    openDoor2 = botDoorPath;
    openDoor3 = beachDoorPath;
  }
}

doorImage1.onclick = () =>{
  doorImage1.src = openDoor1;
}

doorImage2.onclick = () =>{
  doorImage2.src = openDoor2;
}

doorImage3.onclick = () =>{
  doorImage3.src = openDoor3;
}

That’s because the three doors are written in invalid syntax, you either have to put out the equal sign and set it to a value or don’t set it to any value and don’t put out any equal signs.

let openDoor1;
let openDoor2;
let openDoor3;

Or if you have to assign a value to it, or “reset” it you can set it to be undefined

let someVariable = undefined
let anotherVariable;
console.log(someVariable === anotherVariable) // logs true to the console, since undefined is the same as undefined

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