Why is the array lenght as Undefined?

Asked

Viewed 56 times

0

I need to count the size of an array and its lenght gives as Undefined.

Because?

('body').on('click', "#btnGravar", function() {

  $("input:checked").each(function() {
    var infoPedidos = [];
    var classes = $(this).attr("class");
    var value = $(this).data("id");

    if (classes !== undefined && value !== undefined) {
      var idColaborador = $("#cmbColaboradores").val();
      var id = $(this).data("id");
      var protocolo = $(this).data("protocolo");
      var sistema = $(this).data("sistema");
      var equipe = $(this).data("equipe");
      var finalidade = $(this).data("finalidade");
      var fornecedor = $(this).data("fornecedor");

      infoPedidos.push({
        id: id,
        protocolo: protocolo,
        sistema: sistema,
        equipe: equipe,
        finalidade: finalidade,
        fornecedor: fornecedor
      })

      console.log(infoPedidos.lenght);
    }
  });
});

1 answer

1


The syntax is .length and not .lenght.

  • Boy, am I tired of not seeing that? ;(

  • It’s normal :) It happens to everyone, the simplest mistakes are the hardest to find.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.