mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
✨ Add "is-palindrome" challenge
This commit is contained in:
parent
957e13bc5e
commit
7c9c59e5b1
13
challenges/is-palindrome/README.md
Normal file
13
challenges/is-palindrome/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# is-palindrome
|
||||||
|
|
||||||
|
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.
|
||||||
|
|
||||||
|
## Instructions :
|
||||||
|
|
||||||
|
The function should return `true` if a given string (case insensitive) is a palindrome and `false` if it's not the case.
|
||||||
|
|
||||||
|
**Note :** a **Palindrome** is a word, phrase, or sequence that reads the **same backwards as forwards**, e.g. Kayak.
|
||||||
|
|
||||||
|
## Examples :
|
||||||
|
|
||||||
|
See the `input-output.json` file for examples of input/output.
|
22
challenges/is-palindrome/input-output.json
Normal file
22
challenges/is-palindrome/input-output.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"input": ["kayak"],
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": ["hello"],
|
||||||
|
"output": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": ["Was it a cat I saw"],
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": ["No lemon, no melon"],
|
||||||
|
"output": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"input": ["achievement"],
|
||||||
|
"output": false
|
||||||
|
}
|
||||||
|
]
|
0
challenges/is-palindrome/solutions/.gitkeep
Normal file
0
challenges/is-palindrome/solutions/.gitkeep
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# typescript-palindrome - is-palindrome
|
||||||
|
|
||||||
|
Programming language : TypeScript
|
||||||
|
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.
|
@ -0,0 +1,6 @@
|
|||||||
|
function solution (string: string) {
|
||||||
|
const formattedString = string.replace(/ /g,'').toLowerCase()
|
||||||
|
return formattedString === formattedString.split("").reverse().join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
export default solution
|
Loading…
Reference in New Issue
Block a user