I m new to JavaScript and facing a weird problem. after adding months to asset_purchase_date into a new variable, the value of asset_purchase_date is changing automatically.
function AssetValueToday(asset_purchase_date, asset_total_cost, asset_life_months, asset_sale_date, asset_value_ason) {
var return_value = 0;
if (asset_sale_date > asset_value_ason) {
if (asset_value_ason > asset_purchase_date) {
days_since_purchase = (Math.ceil(Math.abs(asset_value_ason - asset_purchase_date)) / (1000 * 60 * 60 * 24));
asset_end_date = addMonths(asset_purchase_date, asset_life_months);
// here do some stuff
}
return_value = asset_purchase_date;
} else {
return_value = 0;
}
return return_value;
}
function addMonths(date, months) {
date.setMonth(date.getMonth() + months);
return date;
}
Any help shall be highly appreciated.