The
The problem I turn to another array to array I when I try to push the new array, it just Add another index
Here's my array:.
var EmailAddr = [{customer ID: "C20l2ll2l22l327_249" email: "Fanjavaid@gmailskcom" files: [ "20l4090lll4ll06_082895250262", "20l4l00lll7l208_082895250262"]}, {customer ID " C20121121221327_300 ", email:" fandi.java@gmail.com ", files: [" 201409011141106_xxx ",]}];
Here's my code to create a new code:
var penampungan = []; For (var i = 0; i & LT; emailAddr.length; i ++) {var data = {customer ID: emailAddr [i] .customerID, email: emailAddr [i] .email}; For (; j & LT; var j = 0 emailAddr [i] .files.length; J ++) {data [ 'master'] = EmailAddr [I] Kfiles [J] ".pdf"; Data ['expansion'] = email ginger [i] .file [ja] + "_detail.pdf"; Penampungan.push (data); }} Console.log (penampungan);
I expect results like this:
var newArray = [{customer ID: "C20121121221327_249", e-mail: "fanjavaid@gmail.com", Master: "201409011141106_082895250262.pdf", Description: "201409011141106_082895250262_detail.pdf"}, {customerID: "C201211212217_249", email: "fanjavaid@gmail.com", Master: "201410011171208_082895250262.pdf", extension: "201410011171208_082895250262_detail.pdf"} , {CustomerID: "C20121121221327_300", Email: "fandi.java@gmail.com", Master: "201409011141106_xxx.pdf", extension: "201409011141106_xxx_detail.pdf"}];
How to do this?
Thank you.
You transferring data built to the inner loop
on penampungan = []; (Var i = 0; i & lt; emailAddr.length; i ++) {for (var j = 0; j & lt; email other [i]. Files.length; j ++) {var data = {customerID : EmailAddr [i] Customer ID, email: email address [i] .email}; Data ['master'] = email ginger [i] .file [ja] + ".pdf"; Data ['expansion'] = email ginger [i] .file [ja] + "_detail.pdf"; Penampungan.push (data); }}
Comments
Post a Comment