2
I need x to be added to 7 after the loop, but I’m not getting it, the code works perfectly if I do x++, is there any way to make that sum with 7?
var x;
for (x = dtdia + 2; x <= 31; x+ 7){
console.log(x);
};
Explaining the context, I want to save an event weekly in the database, so I thought I’d create a loop that identifies today and the day of the week that this event will take place and add up to 7 until the 31st. The complete code to better understand:
var dt = new Date();
var weekday = dt.getDay();
var dtdia = dt.getDate();
var diasem = document.getElementById('DiaSem').value;
var soma = weekday - diasem;
switch (soma) {
case -1:
// 1dia
var x;
for (x = dtdia + 1; x <= 31; x+ 7){
console.log(x);
};
break;
case -2:
// 2dia
var x;
for (x = dtdia + 2; x <= 31; x+ 7){
console.log(x);
};
break;
};
But since doing with x++ the code would work you could think about putting x=x+6; inside the loop
– user60252