Calculating parking fees, given start and end timestamps Since I have just started Javascript, I am trying to solve a few problems and improve myself. I encountered such a question. I tried to do everything step by step from the question, but I do not think that my code is efficient. Can someone help me develop it?

Please code for a JavaScript function that accepts two arguments that
are; parking &quot;date and time&quot;(timestamp) and return &quot;date and
time&quot;(timestamp). At an airport for car parking, the following rules
are applied.
Parking costs;
€2 for the first 20 minutes,
rising to €4 for up to 40 minutes,
rising to €6 for up to one hour,
rising to €7 for up to two hours,
rising to €9 for up to three hours,
rising to €11 for up to four hours,
rising to €13 for 4-8 hours and
rising to €15 for 8-24 hours.
€16 for the first 24 hours and after that each additional day is
charged at €9.

Here is my code:
function msToHours(milisecond) {
        let time = milisecond;

        let hour = (time / 60000) / 60;

        return hour;
    }


    //Mins to Hours Function
    function minToHours(miniute){

        let time = miniute;

        let hr = (miniute /60);

        return hr;

    }


    //Finding the nth day Function

    function add24HR(hour, cb) {

        let arr = new Array();

        for (let i = 0; i &lt; hour; i++) {
            if (i % 24 == 0) {
                arr.push(i)
            }
        }
    
        return  `Your Parking Fee is £${(arr.length*cb-cb) + 16}.(${arr.length} days)`
    }

    //Main Function

    const parkingFees = (parkingDate, returnDate) =&gt; {

        //Defining dates
        var park = new Date(parkingDate)
        var returned = new Date(returnDate);

        //Variables
        var penaltyFee = 9;
        let totalPrice;


        //Time between park and return (miliseconds)
        let totalTime = returned - park

        //MiliSeconds to Hour
        let totalPark = msToHours(totalTime);

        //Mins to Hours
        if (totalPark &lt;= minToHours(20)) {
            return `Your parking fee is only £${2}.`
        } 

        else if(totalPark &gt; minToHours(20) &amp;&amp; totalPark &lt;= minToHours(40)){
            return `Your parking fee is only £${4}.`
        }

        else if(totalPark &gt; minToHours(40) &amp;&amp; totalPark &lt;= minToHours(60)){
            return `Your parking fee is only £${6}.`
        }
        else if(totalPark &gt; minToHours(60) &amp;&amp; totalPark &lt;= minToHours(120)){
            return `Your parking fee is only £${7}.`
        }
        else if(totalPark &gt; minToHours(120) &amp;&amp; totalPark &lt;= minToHours(180)){
            return `Your parking fee is only £${9}.`
        }
        else if(totalPark &gt; minToHours(180) &amp;&amp; totalPark &lt;= minToHours(240)){
            return `Your parking fee is only £${11}.`
        }
        else if(totalPark &gt; minToHours(240) &amp;&amp; totalPark &lt;= minToHours(480)){
            return `Your fparking fee is only £${13}.`
        }
      
        else if(totalPark &gt; minToHours(480) &amp;&amp; totalPark &lt; minToHours(1440)){
            
            return `Your parking fee is only £${15}.`
        }

        else if(totalPark &gt; minToHours(1440) &amp;&amp; totalPark &lt; minToHours(2880)){
            
            return `Your parking fee is only £${16}.`
        }

        //if totalPark &gt; 24 HRS

        else {

            totalPrice = add24HR(totalPark, penaltyFee)

        }

        return totalPrice;

    }

    document.querySelector(&quot;body&quot;).innerHTML = (parkingFees(&quot;5/12/2020 18:30&quot;, &quot;5/18/2020 18:30&quot;))
The main issue I see with the code is the repetitive if/elses at the bottom. Repetitive code is annoying to write, takes some time to read, and is often a bit more likely to have bugs than DRY code. To identify the parking fee, I'd make an array of ranges and their associated fees, then find the appropriate range:
const getCost = (totalHoursParked) =&gt; {
  const costs = [
    // [Maximum number of hours, Associated cost]
    [1/3, 2],
    [2/3, 4],
    [1, 6],
    [2, 7],
    [3, 9],
    [4, 11],
    [8, 13],
    [24, 15],
  ];
  if (totalHoursParked &gt; 24) {
    const days = Math.ceil(totalHoursParked / 24);
    return 16 + 9 * (days - 1);
  }
  const found = costs.find(([maxHours]) =&gt; totalHoursParked &lt;= maxHours);
  return found[1];
};

Just calculate the hours stayed, then invoke the function above.
Other suggestions regarding your current code:
Always use const when you can - only use let when you must warn readers of the code that you may be reassigning the variable in the future.
Avoid var - If you're going to write in modern ES6+ syntax, great - in which case, better to avoid var, which has problems such as an unintuitive function scope and automatically assigning to a property of the global object when on the top level.
Prefer [] over new Array() -  it's shorter to write and easier to read, and using the constructor may tempt you to pass it a number, which will result in a sparse array (sparse arrays can have some very strange behaviors; better to avoid them entirely).
Prefer strict equality - better to avoid == and !=, since they have confusing coercion rules a reader of the code should not have to have memorized in order to be confident of the logic the code is implementing.
add24HR is weird While you can loop one-by-one over the hours and increment when encountering every 24th, it'd be much easier to just divide the number of hours by 24 and take the .ceil or .floor of it as needed.
Use meaningful, precise variable names that clearly indicate what the variable contains. Would someone just glancing at the script know what park means, or the difference between totalTime and totalPark, without looking at where those are defined? Probably not - better to call them something like parkDate, returnDate, totalMSParked, totalHoursParked. The penaltyFee = 9 doesn't make a whole lot of sense either except after one reads the description of the problem and some of the code. parkingFees is a function, so it should probably have a verb in its name, like calculateParkingFees.
Only use string interpolation when you need to interpolate For example, this:
return `Your parking fee is only £${4}.`

may as well be
return `Your parking fee is only £4.`

Semicolons Some of your lines have semicolons, but a lot of lines are missing semicolons too. Best to be stylistically consistent - either use semicolons or don't. Unless you're an expert, I'd highly recommend using semicolons, else you will probably occasionally run into the pitfalls of automatic semicolon insertion.
In all, I don't think there's much need in the code for anything other than a small wrapper around the getCost function:


const calculateParkingFees = (parkDateStr, returnDateStr) =&gt; {
  const parkDate = new Date(parkDateStr);
  const returnDate = new Date(returnDateStr);
  const totalMSParked = returnDate - parkDate;
  const totalHoursParked = totalMSParked / (1000 * 3600);
  return `Your parking fee is £${getCost(totalHoursParked)}.`;
}

const getCost = (totalHoursParked) =&gt; {
  const costs = [
    // [Maximum number of hours, Associated cost]
    [1/3, 2],
    [2/3, 4],
    [1, 6],
    [2, 7],
    [3, 9],
    [4, 11],
    [8, 13],
    [24, 15],
  ];
  if (totalHoursParked &gt; 24) {
    const days = Math.ceil(totalHoursParked / 24);
    return 16 + 9 * (days - 1);
  }
  const found = costs.find(([maxHours]) =&gt; totalHoursParked &lt;= maxHours);
  return found[1];
};

console.log(calculateParkingFees("5/12/2020 18:30", "5/18/2020 18:30")); // 6 days
console.log(calculateParkingFees("5/12/2020 18:30", "5/12/2020 19:45")); // bit more than an hour
console.log(calculateParkingFees("5/12/2020 18:30", "5/12/2020 19:00")); // 30 minutes