I would like to know how to create new object by two objects in javascript.
iterate through the obj1, and add the obj2 values, create new object in javascript
function getObject(obj1, obj2){
let result={};
Object.keys(obj1).forEach(key=>{
if(key==="start" || key==="end"){
result.time= obj1.start+"-"+obj1.end,
result.qty= obj2.qty
}
})
}
var obj1 ={
start: "16:01", end: "23:59", totalqty: 1065, totalamount: 8229170
}
var obj2 = {
qty: 10,
amt: 120
}
Expected Output
{
time: "16:01-23:59"
val: 10 // represents obj2.qty,
totalqty: 1065,
totalamount: 8229170,
price: 120
}