Published on January 26, 2024By DeveloperBreeze

// Function to calculate the distance between two points in a 2D plane
function calculateDistance(x1, y1, x2, y2) {
    const deltaX = x2 - x1;
    const deltaY = y2 - y1;
    return Math.sqrt(deltaX ** 2 + deltaY ** 2);
}

// Calculate and log the distance between two points (e.g., (0, 0) and (3, 4))
const distance = calculateDistance(0, 0, 3, 4);
console.log('Distance Between Two Points:', distance);

Comments

Please log in to leave a comment.

Continue Reading:

Generate Random Password

Published on January 26, 2024

javascriptpythonphp

Detecting Browser and Version

Published on January 26, 2024

javascript

Detect Dark Mode Preference

Published on January 26, 2024

javascript

Calculate Greatest Common Divisor (GCD) of Two Numbers

Published on January 26, 2024

javascript

Convert Array of Objects to CSV

Published on January 26, 2024

javascript

Validate Password Strength

Published on January 26, 2024

javascript

Parse JSON String to Object

Published on January 26, 2024

javascript