Skip to main content
Fixed a few syntax errors, indented code for better readability and linked the doc to the name of the prototype function.
Source Link
Sebastian Simon
  • 19.8k
  • 8
  • 61
  • 88

You can use the Array.prototype.mapArray.prototype.map function

var newArr = arr.map(function(v, i) {
  return { key: Today + i, value: v }; 
});

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

You can use the Array.prototype.map function

var newArr = arr.map(function(v, i) { return { key: Today + i, value: v }; )

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

You can use the Array.prototype.map function

var newArr = arr.map(function(v, i) {
  return { key: Today + i, value: v };
});
added 7 characters in body
Source Link
aeskreis
  • 2k
  • 2
  • 17
  • 24

You can use the Array.prototype.map function

var newArr = arr.map(function(v, i) { return { key: Today + i, value: v }; )

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

You can use the Array.prototype.map function

var newArr = arr.map(function(v) { return { key: Today, value: v }; )

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

You can use the Array.prototype.map function

var newArr = arr.map(function(v, i) { return { key: Today + i, value: v }; )

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Source Link
aeskreis
  • 2k
  • 2
  • 17
  • 24

You can use the Array.prototype.map function

var newArr = arr.map(function(v) { return { key: Today, value: v }; )

See documentation for this function here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map