update description, run tests
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
Returns `true` if the given string is a palindrome, `false` otherwise.
|
Returns `true` if the given string is a palindrome, `false` otherwise.
|
||||||
|
|
||||||
Convert string `String.toLowerCase()` and use `String.replace()` to remove non-alphanumeric characters from it.
|
Convert string `String.toLowerCase()` and use `String.replace()` to remove non-alphanumeric characters from it.
|
||||||
Then, `String.split('')` into individual characters, `Array.reverse()`, `String.join('')` and compare to the original, unreversed string, after converting it `String.tolowerCase()`.
|
Then, use the spread operator (`...`) to split string into individual characters, `Array.reverse()`, `String.join('')` and compare to the original, unreversed string, after converting it `String.tolowerCase()`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const palindrome = str => {
|
const palindrome = str => {
|
||||||
|
|||||||
@ -1,11 +1,5 @@
|
|||||||
const palindrome = str => {
|
const palindrome = str => {
|
||||||
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
const s = str.toLowerCase().replace(/[\W_]/g, '');
|
||||||
return (
|
return s === [...s].reverse().join('');
|
||||||
s ===
|
|
||||||
s
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.join('')
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
module.exports = palindrome;
|
module.exports = palindrome;
|
||||||
43
test/testlog
43
test/testlog
@ -1,6 +1,6 @@
|
|||||||
Test log for: Wed Apr 25 2018 21:00:18 GMT+0000 (UTC)
|
Test log for: Thu Apr 26 2018 19:20:53 GMT+0200 (CEST)
|
||||||
|
|
||||||
> 30-seconds-of-code@0.0.3 test /home/travis/build/Chalarangelo/30-seconds-of-code
|
> 30-seconds-of-code@0.0.3 test /Users/stefanfejes/Projects/30-seconds-of-code
|
||||||
> tape test/**/*.test.js | tap-spec
|
> tape test/**/*.test.js | tap-spec
|
||||||
|
|
||||||
|
|
||||||
@ -982,7 +982,7 @@ Test log for: Wed Apr 25 2018 21:00:18 GMT+0000 (UTC)
|
|||||||
Testing isTravisCI
|
Testing isTravisCI
|
||||||
|
|
||||||
✔ isTravisCI is a Function
|
✔ isTravisCI is a Function
|
||||||
✔ Running on Travis, correctly evaluates
|
✔ Not running on Travis, correctly evaluates
|
||||||
|
|
||||||
Testing isTypedArray
|
Testing isTypedArray
|
||||||
|
|
||||||
@ -1724,9 +1724,25 @@ Test log for: Wed Apr 25 2018 21:00:18 GMT+0000 (UTC)
|
|||||||
Testing toCurrency
|
Testing toCurrency
|
||||||
|
|
||||||
✔ toCurrency is a Function
|
✔ toCurrency is a Function
|
||||||
✔ currency: Euro | currencyLangFormat: Local
|
|
||||||
|
✖ currency: Euro | currencyLangFormat: Local
|
||||||
|
---------------------------------------------
|
||||||
|
operator: equal
|
||||||
|
expected: '€ 123,456.79'
|
||||||
|
actual: '€123,456.79'
|
||||||
|
at: Test.test (/Users/stefanfejes/Projects/30-seconds-of-code/test/toCurrency/toCurrency.test.js:8:5)
|
||||||
|
stack: |-
|
||||||
|
|
||||||
✔ currency: US Dollar | currencyLangFormat: English (United States)
|
✔ currency: US Dollar | currencyLangFormat: English (United States)
|
||||||
✔ currency: Japanese Yen | currencyLangFormat: Local
|
|
||||||
|
✖ currency: Japanese Yen | currencyLangFormat: Local
|
||||||
|
-----------------------------------------------------
|
||||||
|
operator: equal
|
||||||
|
expected: 'JP¥ 322,342,436,423'
|
||||||
|
actual: '¥322,342,436,423'
|
||||||
|
at: Test.test (/Users/stefanfejes/Projects/30-seconds-of-code/test/toCurrency/toCurrency.test.js:11:5)
|
||||||
|
stack: |-
|
||||||
|
|
||||||
|
|
||||||
Testing toDecimalMark
|
Testing toDecimalMark
|
||||||
|
|
||||||
@ -1995,13 +2011,24 @@ Test log for: Wed Apr 25 2018 21:00:18 GMT+0000 (UTC)
|
|||||||
✔ Sends a GET request
|
✔ Sends a GET request
|
||||||
✔ Runs the function provided
|
✔ Runs the function provided
|
||||||
✔ Runs promises in series
|
✔ Runs promises in series
|
||||||
✔ Works as expecting, passing arguments properly
|
|
||||||
✔ Sends a POST request
|
✔ Sends a POST request
|
||||||
|
✔ Works as expecting, passing arguments properly
|
||||||
✔ Works with multiple promises
|
✔ Works with multiple promises
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Failed Tests: There were 2 failures
|
||||||
|
|
||||||
|
Testing toCurrency
|
||||||
|
|
||||||
|
✖ currency: Euro | currencyLangFormat: Local
|
||||||
|
✖ currency: Japanese Yen | currencyLangFormat: Local
|
||||||
|
|
||||||
|
|
||||||
total: 1014
|
total: 1014
|
||||||
passing: 1014
|
passing: 1012
|
||||||
duration: 2.3s
|
failing: 2
|
||||||
|
duration: 2.4s
|
||||||
|
|
||||||
|
|
||||||
|
undefined
|
||||||
Reference in New Issue
Block a user