NYC Taxi Price Calculator & Fare Guide
:root {
–primary-color: #004a99;
–success-color: #28a745;
–background-color: #f8f9fa;
–text-color: #333;
–border-color: #ddd;
–shadow-color: rgba(0, 0, 0, 0.1);
–card-background: #fff;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(–background-color);
color: var(–text-color);
line-height: 1.6;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.container {
width: 100%;
max-width: 960px;
margin: 20px auto;
padding: 20px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: 0 4px 12px var(–shadow-color);
}
header {
background-color: var(–primary-color);
color: white;
padding: 20px 0;
text-align: center;
width: 100%;
}
header h1 {
margin: 0;
font-size: 2.5em;
}
main {
width: 100%;
}
section {
margin-bottom: 30px;
padding: 25px;
background-color: var(–card-background);
border-radius: 8px;
box-shadow: 0 2px 8px var(–shadow-color);
}
h2, h3 {
color: var(–primary-color);
margin-bottom: 15px;
}
.loan-calc-container {
background-color: var(–card-background);
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 8px var(–shadow-color);
margin-bottom: 30px;
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: var(–primary-color);
}
.input-group input[type="number"],
.input-group select {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid var(–border-color);
border-radius: 4px;
font-size: 1em;
box-sizing: border-box;
}
.input-group .helper-text {
font-size: 0.85em;
color: #666;
margin-top: 5px;
display: block;
}
.input-group .error-message {
color: red;
font-size: 0.8em;
margin-top: 5px;
display: none; /* Hidden by default */
}
.button-group {
display: flex;
justify-content: space-between;
margin-top: 25px;
gap: 10px;
}
button {
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
font-weight: bold;
transition: background-color 0.3s ease;
}
.btn-primary {
background-color: var(–primary-color);
color: white;
}
.btn-primary:hover {
background-color: #003366;
}
.btn-secondary {
background-color: #6c757d;
color: white;
}
.btn-secondary:hover {
background-color: #5a6268;
}
.btn-success {
background-color: var(–success-color);
color: white;
}
.btn-success:hover {
background-color: #218838;
}
#result {
background-color: var(–primary-color);
color: white;
padding: 20px;
border-radius: 8px;
text-align: center;
margin-top: 25px;
box-shadow: 0 4px 10px var(–shadow-color);
}
#result h3 {
color: white;
margin-bottom: 10px;
font-size: 1.4em;
}
#result .main-result {
font-size: 2.5em;
font-weight: bold;
margin-bottom: 15px;
}
#result .intermediate-values div {
margin-bottom: 8px;
font-size: 1.1em;
}
#result .formula-explanation {
font-size: 0.9em;
opacity: 0.8;
margin-top: 15px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
margin-bottom: 20px;
}
th, td {
border: 1px solid var(–border-color);
padding: 10px;
text-align: left;
}
th {
background-color: var(–primary-color);
color: white;
font-weight: bold;
}
tr:nth-child(even) {
background-color: #e9ecef;
}
caption {
font-size: 1.1em;
font-weight: bold;
color: var(–primary-color);
margin-bottom: 10px;
caption-side: top;
text-align: left;
}
#chartContainer {
text-align: center;
margin-top: 20px;
background-color: var(–card-background);
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px var(–shadow-color);
}
#chartContainer canvas {
max-width: 100%;
height: auto;
}
.faq-section {
background-color: var(–card-background);
padding: 25px;
border-radius: 8px;
box-shadow: 0 2px 8px var(–shadow-color);
}
.faq-section h3 {
margin-bottom: 20px;
}
.faq-item {
margin-bottom: 15px;
}
.faq-item strong {
display: block;
color: var(–primary-color);
margin-bottom: 5px;
cursor: pointer;
}
.faq-item p {
margin-left: 15px;
font-size: 0.95em;
color: #555;
}
.related-links {
background-color: var(–card-background);
padding: 25px;
border-radius: 8px;
box-shadow: 0 2px 8px var(–shadow-color);
}
.related-links h3 {
margin-bottom: 20px;
}
.related-links ul {
list-style: none;
padding: 0;
}
.related-links li {
margin-bottom: 10px;
}
.related-links a {
color: var(–primary-color);
text-decoration: none;
font-weight: bold;
}
.related-links a:hover {
text-decoration: underline;
}
.related-links p {
font-size: 0.9em;
color: #666;
margin-top: 5px;
}
footer {
text-align: center;
padding: 20px;
margin-top: 30px;
width: 100%;
font-size: 0.9em;
color: #777;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.container {
padding: 15px;
}
header h1 {
font-size: 1.8em;
}
button {
padding: 10px 15px;
font-size: 0.95em;
}
.button-group {
flex-direction: column;
}
#result .main-result {
font-size: 2em;
}
}
NYC Taxi Price Calculator
Estimate Your NYC Taxi Fare
Use this calculator to estimate the cost of your taxi ride in New York City. Enter the distance and estimated time, and we'll provide a fare breakdown including meter charges, surcharges, and a suggested tip.
Estimated Taxi Fare Breakdown
NYC Taxi Fare Components
| Component |
Rate |
Notes |
| Flag Drop |
$2.50 |
Initial charge when the meter starts. |
| Per 1/5 Mile |
$0.50 |
Charged for each 1/5 mile traveled. |
| Per Minute (Wait/Trolley Time) |
$0.20 |
Charged for time spent stopped or in slow traffic. |
| Night Surcharge |
$0.50 |
Applies between 8 PM and 6 AM. |
| Rush Hour Surcharge |
$1.00 |
Applies between 4 PM and 8 PM on weekdays. |
| State Tax |
$0.50 |
Flat tax per ride. |
| JFK/LGA Airport Surcharge |
$5.00 |
For trips originating at JFK or LGA airports. |
| New York State Tax |
$1.25 |
Additional tax for rides over $20.00. |
What is the NYC Taxi Price Calculator?
The NYC taxi price calculator is a digital tool designed to help passengers estimate the cost of a taxi ride within New York City. It takes into account various factors that contribute to the final fare, including distance traveled, time spent in the taxi (especially during traffic or stops), and applicable surcharges. This nyc taxi price calculator aims to provide transparency and predictability for riders navigating the city's iconic yellow cabs.
Who should use it? Tourists visiting New York City, residents looking to budget their transportation costs, business travelers needing to track expenses, and anyone curious about taxi fares will find this nyc taxi price calculator invaluable. It's particularly useful for planning trips to and from airports or during peak traffic hours.
Common misconceptions about NYC taxi fares often revolve around fixed pricing. Unlike some other cities, NYC taxi fares are metered, meaning they increase with distance and time. Another misconception is that the fare is solely based on distance; the time component, especially in congested areas, significantly impacts the final cost. This nyc taxi price calculator helps clarify these nuances.
NYC Taxi Price Calculator Formula and Mathematical Explanation
The calculation for an NYC taxi fare involves several components. Our NYC taxi price calculator simplifies this by using the following formula:
Total Fare = (Meter Fare + Surcharges) * (1 + Tip Percentage)
Where:
- Meter Fare is calculated based on the distance and time.
- Surcharges are fixed amounts added under specific conditions.
- Tip Percentage is the gratuity added by the user.
Step-by-step derivation:
- Calculate Distance Fare: The base fare includes a flag drop. Then, for every 1/5 mile traveled, a charge is added.
Distance Fare = Flag Drop + (Distance in Miles * 5 * Per 1/5 Mile Rate)
- Calculate Time Fare: For every minute spent waiting or in slow traffic, a charge is added.
Time Fare = Duration in Minutes * Per Minute Rate
- Calculate Meter Fare: This is the sum of the distance and time fares.
Meter Fare = Distance Fare + Time Fare
- Calculate Applicable Surcharges: Add any relevant surcharges (Night, Rush Hour, Airport, State Tax). For simplicity in this calculator, we'll use a combined estimate or specific inputs if available. For this calculator, we'll use a simplified approach for common surcharges.
Base Surcharges = Night Surcharge (if applicable) + Rush Hour Surcharge (if applicable) + State Tax
Airport Surcharge (if applicable)
Total Surcharges = Base Surcharges + Airport Surcharge
- Calculate Subtotal: Meter Fare plus Total Surcharges.
Subtotal = Meter Fare + Total Surcharges
- Calculate Tip Amount: The tip is calculated on the Meter Fare plus Surcharges (excluding airport surcharge for tip calculation basis, as per common practice, though this can vary). For simplicity, we calculate tip on Meter Fare + Base Surcharges.
Tip Amount = (Meter Fare + Base Surcharges) * Tip Percentage
- Calculate Total Fare: Subtotal plus Tip Amount.
Total Fare = Subtotal + Tip Amount
Variable Explanations:
| Variable |
Meaning |
Unit |
Typical Range |
| Distance |
The total distance of the taxi trip. |
Miles |
0.1 – 50+ |
| Duration |
The total time spent in the taxi, including stops. |
Minutes |
1 – 120+ |
| Tip Percentage |
The percentage of the fare to be added as a tip. |
% |
0% – 25%+ |
| Flag Drop |
Initial charge to start the meter. |
USD |
$2.50 |
| Per 1/5 Mile Rate |
Cost for each 1/5 mile increment. |
USD |
$0.50 |
| Per Minute Rate |
Cost for each minute of waiting or slow traffic. |
USD |
$0.20 |
| Night Surcharge |
Additional charge during late hours. |
USD |
$0.50 |
| Rush Hour Surcharge |
Additional charge during peak commute times. |
USD |
$1.00 |
| State Tax |
Mandatory state tax per ride. |
USD |
$0.50 |
| Airport Surcharge |
Charge for trips starting at JFK or LGA. |
USD |
$5.00 |
| New York State Tax |
Additional tax for higher fares. |
USD |
$1.25 |
Practical Examples (Real-World Use Cases)
Example 1: Midtown to JFK Airport during the day
A tourist takes a taxi from Midtown Manhattan to JFK Airport on a Tuesday afternoon. The trip covers 15 miles and takes approximately 60 minutes due to moderate traffic.
Inputs:
- Trip Distance: 15 miles
- Trip Duration: 60 minutes
- Tip Percentage: 20%
- Airport Trip: Yes (JFK)
- Time of Day: Day (No Night Surcharge)
- Day of Week: Weekday (No Rush Hour Surcharge if outside 4-8 PM)
Calculation Breakdown:
- Flag Drop: $2.50
- Distance Fare: 15 miles * 5 increments/mile * $0.50/increment = $37.50
- Time Fare: 60 minutes * $0.20/minute = $12.00
- Meter Fare: $37.50 + $12.00 = $49.50
- Surcharges: State Tax ($0.50) + JFK Surcharge ($5.00) + NY State Tax ($1.25) = $6.75
- Subtotal (Meter + Surcharges): $49.50 + $6.75 = $56.25
- Tip Amount (20% of $56.25): $11.25
- Total Estimated Fare: $56.25 + $11.25 = $67.50
Financial Interpretation: This example shows how airport trips incur significant surcharges. The long duration due to traffic also adds considerably to the meter fare. A 20% tip on the total meter and surcharge cost is standard.
Example 2: Short trip across town during evening rush hour
A local needs to travel 3 miles across town, taking about 30 minutes due to heavy evening rush hour traffic. They plan to tip 15%.
Inputs:
- Trip Distance: 3 miles
- Trip Duration: 30 minutes
- Tip Percentage: 15%
- Airport Trip: No
- Time of Day: Evening (Assume 4 PM – 8 PM for Rush Hour Surcharge)
- Day of Week: Weekday
Calculation Breakdown:
- Flag Drop: $2.50
- Distance Fare: 3 miles * 5 increments/mile * $0.50/increment = $7.50
- Time Fare: 30 minutes * $0.20/minute = $6.00
- Meter Fare: $7.50 + $6.00 = $13.50
- Surcharges: State Tax ($0.50) + Rush Hour Surcharge ($1.00) + NY State Tax ($1.25) = $2.75
- Subtotal (Meter + Surcharges): $13.50 + $2.75 = $16.25
- Tip Amount (15% of $16.25): $2.44
- Total Estimated Fare: $16.25 + $2.44 = $18.69
Financial Interpretation: This scenario highlights the impact of rush hour. Even for a short distance, the time spent in traffic significantly increases the fare. The nyc taxi price calculator helps users anticipate these costs.
How to Use This NYC Taxi Price Calculator
Using our NYC taxi price calculator is straightforward. Follow these steps to get an accurate fare estimate:
- Enter Trip Distance: Input the approximate distance of your taxi ride in miles into the "Trip Distance" field.
- Enter Trip Duration: Estimate the total time the trip will take in minutes, including any potential stops or slow traffic, and enter it into the "Trip Duration" field.
- Select Tip Percentage: Choose your desired tip percentage from the dropdown menu (15%, 20%, or 25% are common).
- Consider Surcharges: The calculator automatically includes standard surcharges like the State Tax. For specific airport trips (JFK/LGA) or rides during night/rush hours, be aware these may add to the final cost, though this calculator simplifies some of these based on typical inputs.
- Click "Calculate Fare": Press the button to see your estimated total fare.
How to read results: The calculator displays the main estimated total fare prominently. It also breaks down the fare into key components: the base meter fare (distance + time), applicable surcharges, and the calculated tip amount. This detailed view helps you understand where your money is going.
Decision-making guidance: Use the estimates to budget for your trips. If the estimated fare seems high, consider alternative transportation options like the subway (a much cheaper NYC subway fare guide) or ride-sharing services. For frequent travelers, understanding these costs can inform choices about accommodation location relative to destinations.
Key Factors That Affect NYC Taxi Fare Results
Several factors influence the final cost of an NYC taxi ride, and our NYC taxi price calculator attempts to model these:
- Distance Traveled: This is a primary driver. The meter increases for every 1/5 mile, making longer trips inherently more expensive. Planning routes to be direct can save money.
- Trip Duration & Traffic Conditions: The per-minute charge for waiting or slow traffic can significantly inflate the fare, especially during peak hours or in congested areas. This is why a short distance can sometimes cost more than a longer one if traffic is bad.
- Time of Day (Night Surcharge): Rides taken between 8 PM and 6 AM incur a $0.50 surcharge, adding to the overall cost.
- Day of Week & Time (Rush Hour Surcharge): Weekdays between 4 PM and 8 PM attract a $1.00 surcharge due to heavy traffic demand.
- Starting/Ending Location (Airport Surcharges): Trips originating from JFK or LGA airports have a fixed $5.00 surcharge.
- Tolls: If your trip involves crossing bridges or tunnels with tolls (e.g., to New Jersey), these costs are typically added to the fare. This calculator does not explicitly include tolls but they are a significant factor for certain routes.
- Tip Amount: While not part of the metered fare, the tip is a substantial addition to the total out-of-pocket cost for the passenger. Standard tipping practices in NYC range from 15% to 25%.
- New York State Taxes: Flat taxes and additional taxes on fares over a certain amount are mandated and added to the final bill.
Frequently Asked Questions (FAQ)
Q1: Is the NYC taxi price calculator accurate?
A1: The calculator provides a close estimate based on standard rates and common surcharges. Actual fares may vary slightly due to real-time traffic fluctuations, exact mileage, specific toll charges, and driver discretion on certain routes.
Q2: How is the "Per Minute" charge calculated?
A2: The "Per Minute" charge applies when the taxi is stopped or moving at a speed too slow to register distance on the meter. It's calculated based on a rate of $0.20 per minute.
Q3: Do I have to pay the airport surcharge if I'm dropped off at JFK/LGA?
A3: The $5.00 airport surcharge typically applies to trips *originating* from JFK or LGA airports. Drop-offs at these airports usually do not incur this specific surcharge, but standard metered rates and other taxes/tolls will apply.
Q4: Can I pay with a credit card in an NYC taxi?
A4: Yes, all licensed NYC yellow taxis are required to accept credit cards, debit cards, and mobile payments. You can also pay with cash.
Q5: What's the difference between a yellow cab and a green Boro Taxi?
A5: Yellow cabs can pick up street hails anywhere in the city and can be hailed at airports. Green Boro Taxis can only pick up street hails in the five boroughs *outside* of Manhattan's central business district (below 96th St uptown and 110th St crosstown). They cannot be hailed at airports.
Q6: How are tolls handled?
A6: Tolls incurred during your trip are added directly to your fare. The driver will usually ask if you prefer to pay cash or use the taxi's E-ZPass account, which might offer a slightly reduced rate.
Q7: Is tipping mandatory in NYC taxis?
A7: Tipping is not legally mandatory, but it is a customary practice in the service industry. A tip of 15-20% is standard for good service.
Q8: How does the "New York State Tax" work?
A8: There's a $0.50 State Tax on all rides. Additionally, a $1.25 "New York State Tax" is applied to fares that exceed $20.00 (before tip).
var chartInstance = null; // Global variable to hold chart instance
function calculateFare() {
// Clear previous errors
document.getElementById('distanceError').style.display = 'none';
document.getElementById('durationError').style.display = 'none';
// Get input values
var distance = parseFloat(document.getElementById('distance').value);
var duration = parseFloat(document.getElementById('duration').value);
var tipPercentage = parseFloat(document.getElementById('tipPercentage').value);
// — Input Validation —
var isValid = true;
if (isNaN(distance) || distance <= 0) {
document.getElementById('distanceError').textContent = 'Please enter a valid distance (greater than 0).';
document.getElementById('distanceError').style.display = 'block';
isValid = false;
}
if (isNaN(duration) || duration $20
if (meterFare > 20.00) {
calculatedSurcharges += nyStateTaxOver20;
}
// If we had inputs for airport, night, rush hour, they'd be added here.
// Example: if (isAirportTrip) calculatedSurcharges += airportSurcharge;
// Example: if (isNightTime) calculatedSurcharges += nightSurcharge;
// Example: if (isRushHour) calculatedSurcharges += rushHourSurcharge;
var totalSurcharges = calculatedSurcharges; // Simplified
// Calculate Subtotal
var subtotal = meterFare + totalSurcharges;
// Calculate Tip Amount
var tipAmount = subtotal * (tipPercentage / 100);
// Calculate Total Fare
var totalFare = subtotal + tipAmount;
// — Display Results —
document.getElementById('totalFare').textContent = '$' + totalFare.toFixed(2);
document.getElementById('meterFare').textContent = 'Meter Fare: $' + meterFare.toFixed(2);
document.getElementById('surcharges').textContent = 'Surcharges: $' + totalSurcharges.toFixed(2);
document.getElementById('tipAmount').textContent = 'Tip (' + tipPercentage + '%): $' + tipAmount.toFixed(2);
var formulaExplanation = "Fare = (Flag Drop + Distance Fare + Time Fare + Surcharges) * (1 + Tip Percentage). ";
formulaExplanation += "Distance Fare = " + distance + " miles * 5 * $" + perFifthMileRate + ". ";
formulaExplanation += "Time Fare = " + duration + " mins * $" + perMinuteRate + ". ";
formulaExplanation += "Surcharges include State Tax ($" + stateTax + ") and potentially others.";
document.getElementsByClassName('formula-explanation')[0].textContent = formulaExplanation;
document.getElementById('result').style.display = 'block';
// — Update Chart —
updateChart(meterFare, totalSurcharges, tipAmount);
}
function updateChart(meterFare, surcharges, tipAmount) {
var ctx = document.getElementById('fareChart').getContext('2d');
// Destroy previous chart instance if it exists
if (chartInstance) {
chartInstance.destroy();
}
// Create new chart instance
chartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Meter Fare', 'Surcharges', 'Tip'],
datasets: [{
label: 'Fare Components',
data: [meterFare, surcharges, tipAmount],
backgroundColor: [
'rgba(0, 74, 153, 0.7)', // Primary color
'rgba(40, 167, 69, 0.7)', // Success color
'rgba(108, 117, 125, 0.7)' // Secondary color
],
borderColor: [
'rgba(0, 74, 153, 1)',
'rgba(40, 167, 69, 1)',
'rgba(108, 117, 125, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) {
return '$' + value.toFixed(2);
}
}
}
},
plugins: {
legend: {
display: false // Hide legend as labels are on bars
},
title: {
display: true,
text: 'NYC Taxi Fare Breakdown'
}
}
}
});
// Update chart legend manually if needed (or rely on chart labels)
var legendHtml = '
Fare Breakdown: ';
legendHtml += '
■ Meter Fare ';
legendHtml += '
■ Surcharges ';
legendHtml += '
■ Tip';
document.getElementById('chartLegend').innerHTML = legendHtml;
}
function resetCalculator() {
document.getElementById('distance').value = 5;
document.getElementById('duration').value = 15;
document.getElementById('tipPercentage').value = 20;
document.getElementById('distanceError').style.display = 'none';
document.getElementById('durationError').style.display = 'none';
document.getElementById('result').style.display = 'none';
// Clear chart
if (chartInstance) {
chartInstance.destroy();
chartInstance = null;
}
document.getElementById('fareChart').getContext('2d').clearRect(0, 0, document.getElementById('fareChart').width, document.getElementById('fareChart').height);
document.getElementById('chartLegend').innerHTML = ";
}
function copyResults() {
var totalFare = document.getElementById('totalFare').textContent;
var meterFare = document.getElementById('meterFare').textContent;
var surcharges = document.getElementById('surcharges').textContent;
var tipAmount = document.getElementById('tipAmount').textContent;
var formula = document.querySelector('.formula-explanation').textContent;
var assumptions = "Key Assumptions:\n";
assumptions += "Distance: " + document.getElementById('distance').value + " miles\n";
assumptions += "Duration: " + document.getElementById('duration').value + " minutes\n";
assumptions += "Tip Percentage: " + document.getElementById('tipPercentage').value + "%\n";
// Add notes about simplified surcharges if applicable
var textToCopy = "— NYC Taxi Fare Estimate —\n\n";
textToCopy += "Total Estimated Fare: " + totalFare + "\n";
textToCopy += meterFare + "\n";
textToCopy += surcharges + "\n";
textToCopy += tipAmount + "\n\n";
textToCopy += "Formula Used: " + formula + "\n\n";
textToCopy += assumptions;
// Use a temporary textarea to copy text
var textArea = document.createElement("textarea");
textArea.value = textToCopy;
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'Results copied to clipboard!' : 'Failed to copy results.';
// Optionally show a temporary message to the user
console.log(msg);
alert(msg); // Simple alert for feedback
} catch (err) {
console.error('Unable to copy results.', err);
alert('Failed to copy results. Please copy manually.');
}
document.body.removeChild(textArea);
}
// Initialize chart on load if needed, or wait for first calculation
// For now, we'll var it be empty until calculateFare is called.
// Add a placeholder canvas element if it doesn't exist
if (!document.getElementById('fareChart')) {
var canvas = document.createElement('canvas');
canvas.id = 'fareChart';
document.getElementById('chartContainer').prepend(canvas);
}
// Load Chart.js library dynamically if not present (or assume it's globally available)
// For this self-contained HTML, we need to include it.
// NOTE: In a real WordPress environment, you'd enqueue this script properly.
// For this single HTML file, we'll assume Chart.js is available or add it via CDN.
// Adding CDN link for Chart.js for standalone functionality:
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/chart.js';
script.onload = function() {
console.log('Chart.js loaded.');
// Optionally call calculateFare() here if you want initial calculation on load
// calculateFare();
};
document.head.appendChild(script);
// Initialize FAQ accordions
var faqItems = document.querySelectorAll('.faq-item strong');
faqItems.forEach(function(item) {
item.addEventListener('click', function() {
var p = this.nextElementSibling;
if (p.style.display === 'block') {
p.style.display = 'none';
} else {
p.style.display = 'block';
}
});
// Initially hide paragraphs
item.nextElementSibling.style.display = 'none';
});