I have to convert two arrays into a single array base on given below condition. a= ["dry chapati", "dry chapati", "dry chapati"] b = ["chapati", "less fat", "no oil"];
I want to convert a and b to as below
c = ["dry chapati" : "chapati", "less fat", "no oil"]
I am trying it as below but not getting desired result as c
let recipe = ["dry chapati", "dry chapati", "dry chapati"];
let tags = ["chapati", "less fat", "no oil"];
let r = [];
for(let i=1; i<recipe.length; i++){
if(recipe[i] == recipe[i+1]){
recipe[i] = tags
// console.log(recipe);
}
}
Please help to find a solution.