Quantcast
Channel: [Q&A - FAQ Neotys] Last questions
Viewing all articles
Browse latest Browse all 2283

Use a string variable inside a JavaScript variable

$
0
0

We have created the follow JavaScript variable, which works fine:
function evaluate() {
return new function() {
var startDate = new Date().toISOString().slice(0, 10);
startDate = new Date(startDate.replace(/-/g, "/"));
var endDate = "", noOfDaysToAdd = 1, count = 0;
while(count < noOfDaysToAdd){
endDate = new Date(startDate.setDate(startDate.getDate() + 1));
if(endDate.getDay() != 0 && endDate.getDay() != 6){
count++;
}
}
var day = endDate.getDate();
var month = endDate.getMonth() + 1;
var year = endDate.getFullYear();

this.futureDate = day + '.' + month + '.' + year;
}
}

We would like to inject a string variable into this JavaScript variable. E.g. we want to set noOfDaysToAdd in another variable and not inside the JavaScript for easier maintenance. Is that possible?


Viewing all articles
Browse latest Browse all 2283

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>