I am new to JavaScript and I'm trying to create a webpage that asks the user "how many nights will you be staying?" The goal is to display something like this: "Total cost for checking in [today's date] and checking out after [number of nights stayed] nights will cost $[total price]."
However, I'm having trouble getting the correct date to display. It currently shows random dates instead of calculating x days from today. For example, if I enter 5 in the prompt, it displays "Total cost for checking in Thu Sep 24 2020 and checking out Wed Jan 01 0245 is $500." This is neither the current year nor is it 5 days from today.
var totalnights = prompt('How many nights will you be staying?');
var today;
var costMsg;
var nights;
function TotalCost(today) {
nights = new Date(new Date().getDate() + (totalnights));
nights = (nights.toDateString());
today = new Date();
today = (today.toDateString());
var Msg = 'Total cost for checking in ' + today + ' and checking out ' + nights + ' is ' + '$' + hotel.roomRate * totalnights ;
return Msg;
}