Skip to content

Commit

Permalink
adding support of numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
nbossard committed Jan 12, 2024
1 parent 053303b commit 6ce60a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

## [1.0.7] - 2024-0X-XX

- adding support of numbers

## [1.0.6] - 2024-01-10

### Changed
Expand Down
6 changes: 6 additions & 0 deletions cycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ let cycles= [
]

describe('findCycle function', () => {
it('should return the next number if current word is a number', () => {
expect(findCycle('1', 1, cycles)).toBe('2');
expect(findCycle('7', 1, cycles)).toBe('8');
expect(findCycle('7', -1, cycles)).toBe('6');
});

it('should return the next word in the cycle when going up', () => {
expect(findCycle('Lundi', 1, cycles)).toBe('Mardi');
expect(findCycle('Vendredi', 1, cycles)).toBe('Samedi');
Expand Down
6 changes: 6 additions & 0 deletions cycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export function findCycle(parCurWord: string, parDirection: number, parCycles: s
let curCycleIndex: number;
let curCycleWordIndex: number;

// checking if it is a number
if (!isNaN(Number(parCurWord))) {
return String(Number(parCurWord) + parDirection);
}

// searching in all cycles
for (let i = 0; i < parCycles.length; i++) {
curCycle = parCycles[i];
curCycleIndex = curCycle.indexOf(parCurWord);
Expand Down

0 comments on commit 6ce60a7

Please sign in to comment.