Skip to main content
added 113 characters in body
Source Link

From what I saw into your example the first pair of elements are the keys for your data, into your example will include them into your final arrays.

This example will generate to a dictionary with the keys Number and Version containing the corresponding values from your array.

var example = [['Version', 'Number'], [ 'V1.0', 1 ], [ 'V2.0', 2 ]];

function extract(items) {
  var keys = {},
      version = items[0][0],
      number = items[0][1];
  
  keys[version] = [];
  keys[number] = [];
   
  return items.slice(1).reduce(function(acc, item) {
    acc[version].push(item[0]);    
    acc[number].push(item[1]);
    
    return acc;
  }, keys);
}

var result = extract(example);
console.log(result);

var example = [['Version', 'Number'], [ 'V1.0', 1 ], [ 'V2.0', 2 ]];

function extract(items) {
  var keys = {},
      version = items[0][0],
      number = items[0][1];
  
  keys[version] = [];
  keys[number] = [];
   
  return items.slice(1).reduce(function(acc, item) {
    acc[version].push(item[0]);    
    acc[number].push(item[1]);
    
    return acc;
  }, keys);
}

var result = extract(example);
console.log(result);

From this point you can do something like:

var labels = result.Version;
var data = result.Number;

From what I saw into your example the first pair of elements are the keys for your data, into your example will include them into your final arrays.

This example will generate to a dictionary with the keys Number and Version containing the corresponding values from your array.

var example = [['Version', 'Number'], [ 'V1.0', 1 ], [ 'V2.0', 2 ]];

function extract(items) {
  var keys = {},
      version = items[0][0],
      number = items[0][1];
  
  keys[version] = [];
  keys[number] = [];
   
  return items.slice(1).reduce(function(acc, item) {
    acc[version].push(item[0]);    
    acc[number].push(item[1]);
    
    return acc;
  }, keys);
}

var result = extract(example);
console.log(result);

From this point you can do something like:

var labels = result.Version;
var data = result.Number;

From what I saw into your example the first pair of elements are the keys for your data, into your example will include them into your final arrays.

This example will generate to a dictionary with the keys Number and Version containing the corresponding values from your array.

var example = [['Version', 'Number'], [ 'V1.0', 1 ], [ 'V2.0', 2 ]];

function extract(items) {
  var keys = {},
      version = items[0][0],
      number = items[0][1];
  
  keys[version] = [];
  keys[number] = [];
   
  return items.slice(1).reduce(function(acc, item) {
    acc[version].push(item[0]);    
    acc[number].push(item[1]);
    
    return acc;
  }, keys);
}

var result = extract(example);
console.log(result);

From this point you can do something like:

var labels = result.Version;
var data = result.Number;
Source Link

From what I saw into your example the first pair of elements are the keys for your data, into your example will include them into your final arrays.

This example will generate to a dictionary with the keys Number and Version containing the corresponding values from your array.

var example = [['Version', 'Number'], [ 'V1.0', 1 ], [ 'V2.0', 2 ]];

function extract(items) {
  var keys = {},
      version = items[0][0],
      number = items[0][1];
  
  keys[version] = [];
  keys[number] = [];
   
  return items.slice(1).reduce(function(acc, item) {
    acc[version].push(item[0]);    
    acc[number].push(item[1]);
    
    return acc;
  }, keys);
}

var result = extract(example);
console.log(result);

From this point you can do something like:

var labels = result.Version;
var data = result.Number;