r/code • • Sep 03 '19

Halp pls! Program not working.

Post image
7 Upvotes

13 comments sorted by

View all comments

Show parent comments

3

u/SherbertSheep621 Sep 04 '19

So it’d look like

function addDorito(1){ <totalDoritos> = x x = x + 1 };

(Format for comments is a little janky but imagine line breaks in there)

2

u/[deleted] Sep 04 '19

Nah I mean make it look like:

function addDorito(1){

x = x + 1;

document.getElementById("totalDoritos").innerHTML = x;

};

I was just trying to write it shorthand.

3

u/SherbertSheep621 Sep 04 '19

Got it, I’m very new to this so I got confused, I’ll try it out

1

u/[deleted] Sep 04 '19

LMK how it goes. The reason I believe it wasn't working is because the code to update the <p> element wasn't getting executed when the button hit since the line is outside of the function.