I have the problem for this situation. I want to print like console.log did in the screen for react native
`
const dString = text;
const days = 30;
let [day, month, year] = dString.split('/');
// month - 1 as month in the Date constructor is zero indexed
const now = new Date(year, month - 1, day);
let loopDay = now;
for (let i = 0; i <= days; i++) {
loopDay.setDate(loopDay.getDate() + 6);
console.log ('Day: ' + loopDay);
}
here’s my code and I want to print in return of function in react-native so result of looping can show on my screen`
2
Answers
One way you could do this is by adding all the loop days to an array like so:
To increase the date you can multiply by
i
to increase the offset.And the you can display them by looping over the
loopDays
like soSolution :
Solution Image
Hope it helps 😊