Skip to content

Function returns true or false based on whether or not a certain index can exist in a certain array length

License

Notifications You must be signed in to change notification settings

writetome51/index-is-valid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

indexIsValid(index, arrayLength): boolean

Returns true or false based on whether or not index can exist in arrayLength.
index can be negative or positive.

Examples

indexIsValid(0, 0); // --> false

indexIsValid(1, 1); // --> false

indexIsValid(-1, 1); // --> true

indexIsValid(1, 2); // --> true

indexIsValid(-2, 2); // --> true

indexIsValid(-3, 2); // --> false

Installation

npm i @writetome51/index-is-valid

Loading

import { indexIsValid } from '@writetome51/index-is-valid';

License

MIT

About

Function returns true or false based on whether or not a certain index can exist in a certain array length

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published