i have a response from frontend as below:
const response = { Lakban: "Merah", Plant: "K103", Kategori: "M2", Jumlah: 103 }
and i have lookup Value from MongoDB with example result as below:
const monthReturnDB = "November"
const shelfLifeDB = 6
and I have function below to get month number:
const getMonth=(monthStr)=>{
return new Date(monthStr+'-1-01').getMonth()+1
}
so what i try to explain is i try to get the format of date based on the monthReturnDB and the "Kategori" type with function below:
let value;
if(response.Kategori ==="M1"){
value = "1" + "/" getMonth(monthReturnDB)+Dates.getFullYear()
}else{
value = "1" + "/" getMonth(monthReturnDB)+(Dates.getFullYear()-1)
}
i expected it to sum the value from the months and year with the shelfLifeDB number, with function below:
let end = new Date(valueDB);
end.setMonth(end.getMonth() + 11);
let curr = new Date()
console.log(curr)
console.log(end.toLocaleString('en-US'),valueDB)
but its not returning the expected result as i want:
the expected result i want is as pic below:
Any explanation where i did wrong here?