We have a
Map<number,any> like this:
const map1 = new Map(); map1.set(0,'alpha'); map1.set(1,'beta'); map1.set(2,'gamma'); map1.set(3,'omega'); map1.set(4,'theta');
If we delete the entry with index
2 the remaining indexes are
We want a function that calculates this result and we want unit tests for it.
First lets document and implement our function:
Notice that the way we documented our function makes it easy to unit test it. Here’s the unit test. Note that we are testing edge conditions: