Finding the number of boxes that fit into a truck using JavaScript (Followup Q) I have made a lot of changes to the code over the course of the evening, but after making most of the suggested changes, the variable that the answer is returning is showing up as "undefined". Could someone please help me find my errors in this code? I have tried and have not been able to find the errors due to my limited knowledge of JS.

&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;script&gt;

  ////////////////////////////    
 // Code by Zachary Holmes //
////////////////////////////

// This program determines the number of boxes that can fit into the back of a truck

// Declaring box size in centimetres, and converting it into metres
var boxHeight = prompt("What is the height of your box in centimetres?") / 100;
var boxWidth = prompt("What is the width of your box in centimetres?") / 100;
var boxLength = prompt("What is the length of your box in centimetres?") / 100;

// Declaring truck size in metres
var truckHeight = prompt("What is the height of your truck in metres?");
var truckWidth = prompt("What is the width of your truck in metres?");
var truckLength = prompt("What is the length of your truck in metres?");

// Declaring variables used in equation
var heightA = boxHeight &gt; 0 ? ((truckHeight / boxHeight) | 0) : 0;
var widthA = boxWidth &gt; 0 ? ((truckWidth / boxWidth) | 0) : 0;
var lengthA = boxLength &gt; 0 ? ((truckLength / boxLength) | 0) : 0;

var heightB = boxHeight &gt; 0 ? ((truckHeight / boxHeight) | 0) : 0;
var widthB = boxWidth &gt; 0 ? ((truckLength / boxWidth) | 0) : 0;
var lengthB = boxLength &gt; 0 ? ((truckWidth / boxLength) | 0) : 0;

var heightC = boxHeight &gt; 0 ? ((truckWidth / boxHeight) | 0) : 0;
var widthC = boxWidth &gt; 0 ? ((truckHeight / boxWidth) | 0) : 0;
var lengthC = boxLength &gt; 0 ? ((truckLength / boxLength) | 0) : 0;

var heightD = boxHeight &gt; 0 ? ((truckWidth / boxHeight) | 0) : 0;
var widthD = boxWidth &gt; 0 ? ((truckLength / boxWidth) | 0) : 0;
var lengthD = boxLength &gt; 0 ? ((truckHeight / boxLength) | 0) : 0;

var heightE = boxHeight &gt; 0 ? ((truckLength / boxHeight) | 0) : 0;
var widthE = boxWidth &gt; 0 ? ((truckWidth / boxWidth) | 0) : 0;
var lengthE = boxLength &gt; 0 ? ((truckHeight / boxLength) | 0) : 0;

var heightF = boxHeight &gt; 0 ? ((truckLength / boxHeight) | 0) : 0;
var widthF = boxWidth &gt; 0 ? ((truckHeight / boxWidth) | 0) : 0;
var lengthF = boxLength &gt; 0 ? ((truckWidth / boxLength) | 0) : 0;

var multiplesA = heightA * widthA * lengthA;
var multiplesB = heightB * widthB * lengthB;
var multiplesC = heightC * widthC * lengthC;
var multiplesD = heightD * widthD * lengthD;
var multiplesE = heightE * widthE * lengthE;
var multiplesF = heightF * widthF * lengthF;

var arrayA = [multiplesB, multiplesC, multiplesD, multiplesE, multiplesF];  
var arrayB = [multiplesA, multiplesC, multiplesD, multiplesE, multiplesF];
var arrayC = [multiplesB, multiplesA, multiplesD, multiplesE, multiplesF];
var arrayD = [multiplesB, multiplesC, multiplesA, multiplesE, multiplesF];
var arrayE = [multiplesB, multiplesC, multiplesD, multiplesA, multiplesF];
var arrayF = [multiplesB, multiplesC, multiplesD, multiplesE, multiplesA];


// Calculations
var boxCount;

if (multiplesA &gt; arrayA)
{
boxCount = multiplesA;
}

else if (multiplesB &gt; arrayB)
{
boxCount = multiplesB;
}

else if (multiplesC &gt; arrayC)
{
boxCount = multiplesC;
}

else if (multiplesD &gt; arrayD)
{
boxCount = multiplesD;
}

else if (multiplesE &gt; arrayE)
{
boxCount = multiplesE;
}

else if (multiplesF &gt; arrayF)
{
boxCount = multiplesF;
}

// Output answer
alert("You can fit up to " + boxCount + (1 == boxCount ? " box" : " boxes") + " into the truck");

&lt;/script&gt;
&lt;/html&gt;
This is an interesting pattern:

var heightA = boxHeight &gt; 0 ? ((truckHeight / boxHeight) | 0) : 0;


I assume you intend to be using integer division here? Ie, 5/2 | 0 = 2? 

Also.. why are you repeatedly declaring different variables with the same values? 

var heightA = boxHeight &gt; 0 ? ((truckHeight / boxHeight) | 0) : 0;
var heightB = boxHeight &gt; 0 ? ((truckHeight / boxHeight) | 0) : 0;
var heightC = boxHeight &gt; 0 ? ((truckWidth / boxHeight) | 0) : 0;


Here you are comparing two fundamentally different types: 

if (multiplesA &gt; arrayA)
{
boxCount = multiplesA;
}


Comparing different data types in Javascript involves the type coercion system, which in javascript is a Bad Thing -- you're basically putting yourself at the mercy of an extremely unpredictable system. But, beyond that, it's not even clear what your intention with this line is -- how does it make sense to compare a float to an array?