diff --git a/doc/api/modules.md b/doc/api/modules.md index 8de9375c561dba..343a3b72bd5318 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -217,7 +217,7 @@ With the following ES Modules: ```mjs // distance.mjs -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } ``` ```mjs @@ -269,7 +269,7 @@ export default class Point { // `distance` is lost to CommonJS consumers of this module, unless it's // added to `Point` as a static property. -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } export { Point as 'module.exports' } ``` @@ -293,7 +293,7 @@ named exports attached to it as properties. For example with the example above, ```mjs -export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; } +export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); } export default class Point { constructor(x, y) { this.x = x; this.y = y; }