**Hello Wix community!**

I have a date Picker variable startDate and endDate.

to calculate the numberOfNights is:

numberOfNights = endDate - startDate;

Now, i have inputs:

var desiredMiles;

var baseRate;

to get the user input for desiredMiles is easy,

but, for baseRate, its suppose to be, for every numberOfNight is $60

so if User chooses 5 nights, its $300.

So…

**Question 1)**

How do i generate a code to iterate the baseRate and Display it.

Variables to be displayed to text are

a) numberOfNights

b) Calculated baseRate

c) desiredMiles.

**Please if you can help me with Question 1 only, i would be very happy, but if you feel you can Handle Question 2, Then i would not know how to repay you. Here it comes:-**

**Question 2:**

After Getting and Displaying the: numberOfNights, baseRate and DesiredMiles, next i would like to Calculate the following:

First, a Variable or Function needs to Generate a randomNumber between 0 and 20.

Then the Total Output would be.

**Total** = [ BaseRate + (desiredMiles * 0.35) ] – [ ( BaseRate + (desiredMiles * 0.35) ) * ( randomNumber/1000 ) ]

*(Note: the [ ] is not an array.)

costPerNight = Total / numberOfNights

Display to the user…

*The total cost for your trip ([startDate]-[endDate]) would be $[total] which includes [desiredMiles] miles. This works out to be $[costPerNight] per night.*

I hope i am not asking too much as i really don’t know how on Earth i am going to achieve this without the Communities Help.

Thanks a Mill for anyone who can attempt any of the Two. thanks…