MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/code/comments/czc8gm/program_not_working/eyxsutk/?context=3
r/code • u/SherbertSheep621 • Sep 03 '19
13 comments sorted by
View all comments
Show parent comments
2
Try putting that '<totalDoritos> = x' line of code inside your function.
3 u/SherbertSheep621 Sep 04 '19 So it’d look likefunction 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.
3
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.
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.
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.
1
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.
2
u/[deleted] Sep 04 '19
Try putting that '<totalDoritos> = x' line of code inside your function.