New to JS! Returning to Coding after over a decade! Need help with something simple

Hey so I’m tryna throw together a little code for fun and practice and I was rocking along good until I ran into this problem and I got a feeling that like with most things coding the issue is super simple and right in front of me. Can someone explain to me where I went wrong?

So in the below code I am trying to take the 4 user inputed variables (sxp, uxp, ess, gxp) and have the function add them together to a fifth value (txp). That’s all :smiley: Any help is appreciated in advance! :smiley:

function updateTXP() {

// Totals up all the various kinds of xp to total xp

var sxp = parseInt(document.getElementById("sxp").value);

var uxp = parseInt(document.getElementById("uxp").value);

var ess = parseInt(document.getElementById("ess").value);

var gxp = parseInt(document.getElementById("gxp").value);

document.getElementById("txp").value = Math.floor(sxp + uxp + ess + gxp);

}

I thought maybe it couldn’t handle multiple variable calls in the same line or something so I tried sxp + 2 and it didn’t work either so idk what I’m doing wrong :open_mouth:

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Is your function getting called?

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