Avatar ·

How to add days to a date in JavaScript? Detailed solution

Hello everyone! I'm a beginner in JavaScript and ran into a problem working with dates. I need to implement functionality where a user enters a number of days, and based on the current date, a new date is calculated after that number of days. For example, today is March 15, 2025, the user enters 10, and I should get March 25, 2025. I tried to do it like this: ```javascript let today = new Date(); let daysToAdd = 10; let futureDate = today + daysToAdd; console.log(futureDate); // Outputs something weird like "Fri Mar 14 2025 12:30:00 GMT+030010" ``` But it doesn't work — the result looks like garbage. I understand that you can't just add a date and a number, but I don't know the correct approach. I tried looking in the documentation but got confused with the Date methods. Please tell me how to