javascript - JS function that counts from multiple inputs - Stack Overflow

PHOTO EMBED

Tue Oct 26 2021 19:13:41 GMT+0000 (UTC)

Saved by @InsaneSuperSand #javascript

const suprqMean = 3.93;
const usabilityMean = 4.06;

const suprqSD = 0.29;
const usabilitySD = 0.29;


function listenForChanges (inputId, logId, output, mean, SD) {
  const input = document.querySelector(inputId);
  const log = document.querySelector(logId);

  input.addEventListener("change", updateValue);

  function updateValue(e) {
    output.textContent = (e.target.value - mean) / SD;
  }
}

listenForChanges("#formGroupExampleInput", "#suprq", suprq, suprqMean, suprqSD)
listenForChanges("#formGroupExampleInput1", "#usability", usability, usabilityMean, usabilitySD)
content_copyCOPY

https://stackoverflow.com/questions/69727853/js-function-that-counts-from-multiple-inputs