I am trying to generate n
arrays with a for loop and push an extra element from another array of n
using for loop to each of these arrays.
var userlist = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'];
var selectlist = ['c', 'f', 'k'];
get_field_options = userlist.filter(function (el) {
return selectlist.indexOf(el) < 0;
});
var selectlen = selectlist.length;
var op_arr = new Array();
for (var i = 0; i < selectlen; i++) {
op_arr[i] = new Array();
op_arr[i] = get_field_options;
op_arr[i].push(selectlist[i]);
console.log(op_arr[i]);
}
here is my working fiddle.
but its adding items to same array each time. what I am doing wrong?