Unanswered question

Use a string variable inside a JavaScript variable

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?

ZKB S.
ZKB S.

ZKB S.

Level
0
22 / 100
points

Answers

ZKB S.
ZKB S.

ZKB S.

Level
0
22 / 100
points

Thanks Neil, the main reason we use the JavaScript instead of the date variable is because we cannot set the future date to a weekend. This script picks the following Monday if a weekend would've been set. The date variable in Neload doesn't offer that feature.