-3

const initialState = {

booksData: [
{"Code":"BK01","price":"5"},
{"code":"BK02","price":"30"},
] 
author: [
{"Code":"BK01","name":"Ravi"},
{"code":"BK02","name":"Suresh"},
] 

};

combinedBooksData: [

{"Code":"BK01","price":"10","name":"Ravi"},
{"code":"BK02","price":"25","name":"Suresh"},

]

Sirushti
  • 65
  • 1
  • 4
  • Hi Sirushti, could you give a little more information? Just posting code isn't really helpful. what have you tried, and what is the expected result? – Steven Sep 26 '18 at 06:26
  • 1
    Possible duplicate of [JavaScript merging objects by id](https://stackoverflow.com/questions/19480008/javascript-merging-objects-by-id) – aravind_reddy Sep 26 '18 at 06:28

1 Answers1

0

this should do the trick

var mergedList = _.map(initialState.booksData, function(item){
    return _.extend(item, _.findIndex(initialState.author, { id: item.Code }));
});