diff --git a/challenges/is-palindrome/README.md b/challenges/is-palindrome/README.md new file mode 100644 index 0000000..b74e865 --- /dev/null +++ b/challenges/is-palindrome/README.md @@ -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. diff --git a/challenges/is-palindrome/input-output.json b/challenges/is-palindrome/input-output.json new file mode 100644 index 0000000..712c88a --- /dev/null +++ b/challenges/is-palindrome/input-output.json @@ -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 + } +] diff --git a/challenges/is-palindrome/solutions/.gitkeep b/challenges/is-palindrome/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/is-palindrome/solutions/typescript-palindrome/README.md b/challenges/is-palindrome/solutions/typescript-palindrome/README.md new file mode 100644 index 0000000..b88e8b9 --- /dev/null +++ b/challenges/is-palindrome/solutions/typescript-palindrome/README.md @@ -0,0 +1,4 @@ +# typescript-palindrome - is-palindrome + +Programming language : TypeScript +Created by [@Divlo](https://github.com/Divlo) at 5 July 2020. diff --git a/challenges/is-palindrome/solutions/typescript-palindrome/solution.ts b/challenges/is-palindrome/solutions/typescript-palindrome/solution.ts new file mode 100644 index 0000000..bee920b --- /dev/null +++ b/challenges/is-palindrome/solutions/typescript-palindrome/solution.ts @@ -0,0 +1,6 @@ +function solution (string: string) { + const formattedString = string.replace(/ /g,'').toLowerCase() + return formattedString === formattedString.split("").reverse().join('') +} + +export default solution