I need to increase an array by 1 in Javascript

0

I have a problem, they have made me repeat a code twice and twice because I do not understand the exercise well, I need to increase an array by +1 and that array does not exceed 9. I would like you to see my code and tell me if I did it right or I'm wrong, I'm learning!.

As far as I understand, should I increase the array index ??? I mean when they tell me to increase the array number I guess it's the space of that array, well hopefully they understand me.

Thanks!.

var arr2 = [];
var limit = 9;

function sumar (num){
  while(num < limit)
  {
    arr2.push(num += 1);
  }
  return arr2;
}

var num = arr2;

console.log(sumar(0));
    
asked by syonrod 06.03.2018 в 22:51
source

0 answers