| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3b9af46 commit 27ae62e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,12 +12,9 @@ const lower = (str) => { | |||
| 12 | 12 | throw new TypeError('Invalid Input Type') | |
| 13 | 13 | } | |
| 14 | 14 | ||
| 15 | - return str | ||
| 16 | - .replace(/[A-Z]/g, (_, indexOfUpperChar) => { | ||
| 17 | - const asciiCode = str.charCodeAt(indexOfUpperChar) | ||
| 18 | - | ||
| 19 | - return String.fromCharCode(asciiCode + 32) | ||
| 20 | - }) | ||
| 15 | + return str.replace( | ||
| 16 | + /[A-Z]/g, (char) => String.fromCharCode(char.charCodeAt() + 32) | ||
| 17 | + ) | ||
| 21 | 18 | } | |
| 22 | 19 | ||
| 23 | - export { lower } | ||
| 20 | + export default lower | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,13 +12,8 @@ const upper = (str) => { | |||
| 12 | 12 | } | |
| 13 | 13 | ||
| 14 | 14 | return str.replace( | |
| 15 | - /[a-z]/g, | ||
| 16 | - (_, indexOfLowerChar) => { | ||
| 17 | - const asciiCode = str.charCodeAt(indexOfLowerChar) | ||
| 18 | - | ||
| 19 | - return String.fromCharCode(asciiCode - 32) | ||
| 20 | - } | ||
| 15 | + /[a-z]/g, (char) => String.fromCharCode(char.charCodeAt() - 32) | ||
| 21 | 16 | ) | |
| 22 | 17 | } | |
| 23 | 18 | ||
| 24 | - export { upper } | ||
| 19 | + export default upper | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - import { lower } from '../Lower' | ||
| 1 | + import lower from '../Lower' | ||
| 2 | 2 | ||
| 3 | 3 | describe('Testing the Lower function', () => { | |
| 4 | 4 | it('Test 1: Check by invalid type', () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | - import { upper } from '../Upper' | ||
| 1 | + import upper from '../Upper' | ||
| 2 | 2 | ||
| 3 | - describe('Upper', () => { | ||
| 3 | + describe('Testing the Upper function', () => { | ||
| 4 | 4 | it('return uppercase strings', () => { | |
| 5 | 5 | expect(upper('hello')).toBe('HELLO') | |
| 6 | 6 | expect(upper('WORLD')).toBe('WORLD') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments