Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add link during filter and mapping in javascript

var options = [
  { name: 'One', assigned: true }, 
  { name: 'Two', assigned: true }, 
  { name: 'Three', assigned: true }, 
];

var reduced = options.reduce(function(filtered, option) {
  if (option.assigned) {
     var someNewValue = { name: option.name, newProperty: 'Foo' }
     filtered.push(someNewValue);
  }
  return filtered;
}, []);

document.getElementById('output').innerHTML = JSON.stringify(reduced);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #link #filter #mapping #javascript
ADD COMMENT
Topic
Name
3+5 =