Created
January 23, 2021 07:44
-
-
Save goldalworming/4f9305d06ae5a5c9356706102241b20f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
datamilestone = [ | |
{milestone_id:"Dog1", milestone_name:"Spot"}, | |
{milestone_id:"Cat1", milestone_name:"Tiger"}, | |
{milestone_id:"Dog2", milestone_name:"Rover"}, | |
{milestone_id:"Cat2", milestone_name:"Leo"} | |
]; | |
datastage = [ | |
{kode:"Dog1", stage:1}, | |
{kode:"Cat2", stage:3} | |
]; | |
//=============== object hasil groupby | |
objstage = { | |
"Dog1" : [{kode:"Dog1",stage:1}], | |
"Cat2" : [{kode:"Cat2",stage:3}] | |
} | |
//masukan data obj ke datamilestone saat looping | |
for (var i = 0; i < datamilestone.rows.length; i++) { | |
key = datamilestone.rows[i].milestone_id | |
datamilestone.rows[i].stage = obj[key]['stage'] | |
} | |
//hasilnya | |
datamilestone = [ | |
{milestone_id:"Dog1", milestone_name:"Spot", stage:1}, | |
{milestone_id:"Cat1", milestone_name:"Tiger", stage:''}, | |
{milestone_id:"Dog2", milestone_name:"Rover", stage:''}, | |
{milestone_id:"Cat2", milestone_name:"Leo", stage:3} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment