mardi 2 juillet 2019

I couldnt get a multiple values out of if else condition

I want to get two values out from the function for a specific condition (on "As_cm" values) and execute some operation on those values. I couldn't do that.

function steelSection() {
  if (As_cm <= 29.2) {
    return [D = 152.4, B = 152.2];
  } else if (As_cm <= 38.3) {
    return {
      D = 157.6,
      B = 152.9];
  } else {
    return [D = 1000, B = 2000];
  }
}
var d = D / 2;
var b = B / 2;
console.log(d);
document.getElementById("flangeWidth").innerHTML = d;
console.log(b);
document.getElementById("depth").innerHTML = b;

expected values for As_cm<= 29.2

d= 152.4 / 2 b= 152.2 / 2

The error message I am getting is

Uncaught TypeError: Cannot set property 'innerHTML' of null

at steelcolumn.js:68

Aucun commentaire:

Enregistrer un commentaire