  C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # JavaScript - Inflation/Escalation with Total over X years  » javascript » JavaScript - Inflation/Escalation with Total over X years

By : Jitendra Singh
Date : October 22 2020, 08:10 AM
this one helps. You need to calculate one more year. In this example you need year 8. Then you can take the percentage of the year and add it to the sum.
In your loop you can use Math.ceil(year). This will round the year up, so with years of 7.373 you will get 8 loops. You can test for this last year and adjust the percentage accordingly: code :
``````let year = 7.373;
let money = 24000;
let num = 0;
let total = 0
let percent = 1 + (3.5 / 100);
for (let y = 1; y <= Math.ceil(year); y++) {
num = num + 1;
money = money * percent
if (y > year) { // year 8
// the sum will only increas .373 of year 8
money *= 1 - (y - year)
console.log(`Calculating \${1- (y-year)} of year \${y}`)
}

//  increment total
total += money

console.log('Year ' + num + ' - ' + money.toLocaleString('en-GB', {
style: 'currency',
currency: 'GBP'
}));
// other stuff
}
console.log(`Total: after \${year} years:`, total.toLocaleString('en-GB', {
style: 'currency',
currency: 'GBP'
}))`````` ## I want fill five years in a drop-down using javascript and the years will be after the current years

By : user3161236
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I want fill five years in a drop-down using javascript and the years will be after the current year. , HTML
code :
``````<form id="someform">
<select id="year"></select>
</form>
``````
``````var myselect = document.getElementById("year"), year = new Date().getFullYear();
``````
``````var myselect = document.getElementById("year"),
startYear = new Date().getFullYear()
count = 5;

(function(select, val, count) {
do {
} while (count);
})(myselect, startYear, count);
`````` ## javascript timestamp from years ago and consider leap years

By : Sumedha Rani
Date : March 29 2020, 07:55 AM
wish of those help The date you create in the second sample corresponds to 1/1 the given year (since you only supply year, day and month default to 0). This is probably not what you want.
If you want people who is a certain age today, you should create a date which corresponds to today and then substract the years, e.g.:
code :
``````var lowDate = new Date;
lowDate.setFullYear(lowDate.getFullYear() - age));
lowTimestamp = lowDate.getTime()
var highDate = new Date;
highDate .setFullYear(highDate .getFullYear() - age + 1));
highTimestamp = highDate.getTime()
`````` ## Javascript function to convert decimal years value into years, months and days

By : Dennis
Date : March 29 2020, 07:55 AM
Hope this helps I need a function to transform decimal values of years in years, months and days. Ex: 1.5 years = 1 year, 6 month. 2.2527397260273973 years = 2 years, 3 months and 1 day. , I think the best way would be to change all to days, for example:
code :
``````function yearsToYearsMonthsDays(value)
{
var totalDays = value * 365;
var years = Math.floor(totalDays/365);
var months = Math.floor((totalDays-(years *365))/30);
var days = Math.floor(totalDays - (years*365) - (months * 30));
var result = years + " years, " + months + " months, " + days + " days";
Logger.log(result);
}
`````` ## How to calculate inflation (CPI) adjusted values over different years in Excel in one formula which is pull-down able?

By : ahmed nasser
Date : March 29 2020, 07:55 AM
it helps some times I would like adjust earnings over a couple years for inflation. , Your values are off by a bit. On my computer:
code :
``````=2.25+(2.25/100*2.49)  --> 2.306025
``````
``````D2:  =B2*FVSCHEDULE(1,C2:\$C\$18/100)
`````` ## how to plot three varaibles(like gdp,inflation,unemployment) for 10 years data in R

By : user908095
Date : March 29 2020, 07:55 AM
To fix the issue you can do my data : , I do something like this
code :
``````library(data.table)

setDT(dt)

dataGraf <- rbind(data[ ,.(Year, value = Unemployment_Rate, Type = "Unemployment_Rate")],
data[ ,.(Year, value = Inflation_Rate, Type = "Inflation_Rate")],
data[ ,.(Year, value = GDP, Type = "GDP")])

ggplot(dataGraf,aes(Year, value, color = Type))+geom_line()+geom_point()
`````` 