Movatterモバイル変換


[0]ホーム

URL:


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

Commitebbd019

Browse files
committed
This is a file that has multiple different ways to see if a word is a Palindrome.
1 parentbf139ce commitebbd019

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎palindrome.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*Write a simple function(less than 160 characters) that returns a boolean indicating whether or not a string is a palindrome.*/
2+
3+
// Function Declaration
4+
functionpalindrome(word){
5+
return[...word.toLowerCase()].reverse().join('')==word.toLowerCase() ?true :false
6+
}
7+
// Function Expression
8+
9+
constpalindrome2=(word)=>[...word.toLowerCase()].reverse().join("")==word.toLowerCase() ?true :false
10+
11+
console.log(palindrome("RaceCar"))
12+
console.log('function palindrome(word){return [...word.toLowerCase()].reverse().join("") == word.toLowerCase() ? true : false}'.length)
13+
14+
console.log(palindrome2("LeVel"))
15+
console.log('const palindrome2 = (word) => [...word.toLowerCase()].reverse().join("") == word.toLowerCase() ? true : false'.length)
16+
17+
18+
// Free Code Camp Version of Palindrome Solution
19+
functionpalindrome(str){return[...str.toLowerCase().replace(/[_*-\\.,\\\\\\(\\)]/g, \"\")].reverse().join(\"\") == str.toLowerCase().replace(/[_*-\\.,\\\\\\(\\) ]/g,\"\") ? true : false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp