From fd927950a8634b3abb610a8f9a138d074040346c Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Mon, 15 Oct 2018 05:10:18 +0000 Subject: [PATCH] Travis build: 639 --- README.md | 4 ++-- docs/string.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bec1ec155..711733883 100644 --- a/README.md +++ b/README.md @@ -7979,8 +7979,8 @@ pad('foobar', 3); // 'foobar' Returns `true` if the given string is a palindrome, `false` otherwise. -Convert string `String.toLowerCase()` and use `String.prototype.replace()` to remove non-alphanumeric characters from it. -Then, use the spread operator (`...`) to split string into individual characters, `Array.prototype.reverse()`, `String.prototype.join('')` and compare to the original, unreversed string, after converting it `String.tolowerCase()`. +Convert the string to `String.prototype.toLowerCase()` and use `String.prototype.replace()` to remove non-alphanumeric characters from it. +Then, use the spread operator (`...`) to split the string into individual characters, `Array.prototype.reverse()`, `String.prototype.join('')` and compare it to the original, unreversed string, after converting it to `String.prototype.toLowerCase()`. ```js const palindrome = str => { diff --git a/docs/string.html b/docs/string.html index cf94a26ce..a37d8c6c4 100644 --- a/docs/string.html +++ b/docs/string.html @@ -188,7 +188,7 @@
pad('cat', 8); // '  cat   '
 pad(String(42), 6, '0'); // '004200'
 pad('foobar', 3); // 'foobar'
-

palindrome

Returns true if the given string is a palindrome, false otherwise.

Convert string String.toLowerCase() and use String.prototype.replace() to remove non-alphanumeric characters from it. Then, use the spread operator (...) to split string into individual characters, Array.prototype.reverse(), String.prototype.join('') and compare to the original, unreversed string, after converting it String.tolowerCase().

const palindrome = str => {
+

palindrome

Returns true if the given string is a palindrome, false otherwise.

Convert the string to String.prototype.toLowerCase() and use String.prototype.replace() to remove non-alphanumeric characters from it. Then, use the spread operator (...) to split the string into individual characters, Array.prototype.reverse(), String.prototype.join('') and compare it to the original, unreversed string, after converting it to String.prototype.toLowerCase().

const palindrome = str => {
   const s = str.toLowerCase().replace(/[\W_]/g, '');
   return s === [...s].reverse().join('');
 };