Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0e0ef1b

Browse files
feat: palindrome task
1 parent c1a379e commit 0e0ef1b

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
File renamed without changes.
File renamed without changes.

‎src/2_palindrome/index.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// --- Task
2+
// Return true if the string is a palindrome or false if it is not.
3+
// Palindromes are strings that form the same word if it is reversed.
4+
// Include spaces and punctuation in determining if the string is a palindrome.
5+
6+
// --- Examples:
7+
// palindrome("appa") === true
8+
// palindrome("qwerty") === false
9+
10+
export const palindrome = (str: string) => {
11+
return '';
12+
}

‎src/2_palindrome/test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { palindrome } from './';
2+
3+
test('palindrome function is defined', () => {
4+
expect(palindrome).toBeDefined();
5+
});
6+
7+
test('"appa" is a palindrome', () => {
8+
expect(palindrome('appa')).toBeTruthy();
9+
});
10+
11+
test('" appa" is not a palindrome', () => {
12+
expect(palindrome(' appa')).toBeFalsy();
13+
});
14+
15+
test('"appa " is not a palindrome', () => {
16+
expect(palindrome('appa ')).toBeFalsy();
17+
});
18+
19+
test('"greetings" is not a palindrome', () => {
20+
expect(palindrome('greetings')).toBeFalsy();
21+
});
22+
23+
test('"1000000001" a palindrome', () => {
24+
expect(palindrome('1000000001')).toBeTruthy();
25+
});
26+
27+
test('"Fish hsif" is not a palindrome', () => {
28+
expect(palindrome('Fish hsif')).toBeFalsy();
29+
});
30+
31+
test('"pennep" a palindrome', () => {
32+
expect(palindrome('pennep')).toBeTruthy();
33+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /