UNPKG

lbc-cecelia-hammond

Version:
12 lines (9 loc) 287 B
/** * Author: dephraiim * License: GPL-3.0 or later * * This uses `round` instead of `floor` or `trunc`, to guard against potential `sqrt` accuracy errors */ const perfectSquare = (num) => Number.isFinite(num) && Math.round(Math.sqrt(num)) ** 2 === num export { perfectSquare }