Q:

unable to add values to array

A few weeks ago I posted my code, that was supposed to add values to an array and then draw rectangles on a canvas. The idea is to start drawing a rectangle where other finishes. Youe write width and height values, click on abutton, round this values and the draw it. But unluckily it doenst work.The problem is that the first value is added to the array, but not the next.. Im working JavaScript. Here is my code, any help will be welcome.
var arrayLargo = [];
var arrayAncho = [];
var ancho = 0;
var largo = 0;

function corta() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var medida2 = document.getElementById('medida2').value;
var medida1 = document.getElementById('medida1').value;
  var corte1 = Math.round(medida1);
  var corte2 = Math.round(medida2);

  arrayLargo.push(corte2);
  arrayAncho.push(corte1);
  //ancho, largo

//metodo para el ancho

    for (var i = 0; i < arrayAncho.length ; i++) {
        ancho += arrayAncho[i];
    }
    if (arrayAncho.length == 1) {
        ctx.fillStyle = "#58FA58";
        ctx.fillRect(0, largo, corte1, corte2);
    }else
    if (medida1 > 122 - ancho) {
            ctx.fillStyle = "#58FA58";
            ctx.fillRect(ancho, largo, corte1, corte2);//ancho, largo
        }
    else {
        ctx.fillStyle = "#58FA58";
        ctx.fillRect(ancho, largo, corte1, corte2);//ancho, largo
    }

    medida1 = 0;
    medida2 = 0;

    /*  
   //metodo para el largo
   if (arrayLargo.length >= 1) {
    for (var i = 0; i < arrayLargo.length ; i++) {
        largo += arrayLargo[i];
        if (medida1 > 244- largo) {
            ctx.fillRect(0, largo, corte1, corte2);//ancho, largo
        }
       }
   }*/

}
function corta is called when you click on a button

A:

A few tips to help you get useful answers (or better yet, to let you solve the problem yourself)

What are you expecting the code to do, and what does it do instead?
Are you getting an error message? (Don't forget to check the error console). If so, what is it, and on which line does it occur?
Have you tried reproducing the problem in a simpler setting? (Making a jsFiddle can be a great help.)  If so, what was the result?

