Skip to content

Function receives an array index and returns the new index that same item would have if the array's order were reversed

License

Notifications You must be signed in to change notification settings

writetome51/get-reverse-index

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

getReverseIndex(
      index,
      arrayLength
): number

Receives array index and returns the new index that same item would have
if the array's order were reversed.

Examples

let arr = ['a', 'b', 'c', 'd', 'e'];   
let index = arr.indexOf('d');
getReverseIndex(index, arr.length);
   // -->  1

arr = [7, 2, 6, 9, 3, 10];
index = arr.indexOf(2);
getReverseIndex(index, arr.length);
   // -->  4

Installation

npm i @writetome51/get-reverse-index

Loading

import {getReverseIndex} from '@writetome51/get-reverse-index';

About

Function receives an array index and returns the new index that same item would have if the array's order were reversed

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published