0.0.4 • Published 4 years ago
@pelevesque/find-nearest-number v0.0.4
find-nearest-number
Finds the nearest number of a given target number.
Node Repository
https://www.npmjs.com/package/@pelevesque/find-nearest-number
Installation
npm install @pelevesque/find-nearest-number
Tests
Command | Description |
---|---|
npm test or npm run test | All Tests Below |
npm run cover | Standard Style |
npm run standard | Coverage |
npm run unit | Unit Tests |
Usage
const findNearestNumber = require('@pelevesque/find-nearest-number')
const num = 45
const arr = [-100, -50, 0, 50, 100]
const result = findNearestNumber(num, arr)
// result === 50