euclidean distance | JavaScript

December 24th, 2021 07:54:07 PM

					
const euclideanDistance = (a, b) => Math.hypot(...Object.keys(a).map(k => b[k] - a[k])); euclideanDistance([1, 1], [2, 3]); // ~2.2361 euclideanDistance([1, 1, 1], [2, 3, 2]); // ~2.4495

Featured Posts