jeudi 20 avril 2017

How to push items into an array using a loop?

I've been trying to output the array contents of spliceJoin in Chrome Developer Tools but it always output undefined

Am I missing something?

var wordPermLength = 2;
var wordPerm = ['ab', 'ac', 'a'];
var spliceJoin = [];

function joinWords() {
  for (i = 0; i < wordPermLength; i++) {
    spliceJoin.push(wordPerm[i].concat(wordPerm[i++]));

  }
}
console.log(spliceJoin);



Aucun commentaire:

Enregistrer un commentaire