Stuck on step 40 of the Javascript Algorithms first project


The image should show the problem and my code. Does anyone have a solution?

no quotes, you need to assign the function here. Also no parenthesis, as you are assigning the function, not the result of calling it

So just button1.onclick = goStore;

?

have you tried writing it in the editor?

Well I tried it but it said it’s incorrect

can you share all your code?

let xp = 0;

let health = 100;

let gold = 50;

let currentWeapon = 0;

let fighting;

let monsterHealth;

let inventory = ["stick"];

const button1 = document.querySelector('#button1');

const button2 = document.querySelector("#button2");

const button3 = document.querySelector("#button3");

const text = document.querySelector("#text");

const xpText = document.querySelector("#xpText");

const healthText = document.querySelector("#healthText");

const goldText = document.querySelector("#goldText");

const monsterStats = document.querySelector("#monsterStats");

const monsterName = document.querySelector("#monsterName");

const monsterHealthText = document.querySelector("#monsterHealth");

function goStore() {
  console.log("Going to store.");
}

function goCave() {
  console.log("Going to cave.");
}

function fightDragon() {
  console.log("Fighting dragon.");
}

This is all the code I have in the js file

and where are you assigning a function to the onclick property?

Just before the first function line. That’s the line freecodecamp has the exercise set to.

I don’t see it in the code you posted

I know I didn’t include it but that’s where it is and it’s what was in the original image in the question

Please post the code you tried and is not passing the tests

button1.onclick = “goStore()”;
button1.onclick = goStore;
button1.onclick = “goStore()”{
};
I’ve tried these so far

I can’t help you if you don’t collaborate
please post all the code in the editor including your trial

remember, no quotes, no parenthesis

don’t worry about it I solved it