I am trying to make a code that will solve for the surface area of a 3D square/rectangle, help please :)


When I insert the numbers the answers are wrong for example I put in that all of the numbers as two which should equal 24 but it equals four-thousand four-hundred and fifty-two

var iHeight = prompt("What is your Height");
var iWidth = prompt("What is your Width");
var iLength = prompt("What is your Length");

var surfaceArea = function (length, width, height) {
  return (length * width * 2) + (length + length + width + width)* height ;



You should review the formula...

2lw + 2lh + 2hw


@cadecodes I also thought the formula for "surface area" seemed strange...

@teraace73468 prompts get strings. Perhaps this is causing your math formulas to do some funky concatenation and/or coercion (think "1" + "1" = "11", "2" + 22 (<--a number) = 222 respectively).

Update: see this stackoverflow for further tips. giyf :slight_smile: