Skip to content

Commit a02c534

Browse files
committed
All tasks completed
1 parent 05537c9 commit a02c534

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: index.js

+16
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,19 @@ const result = wordArray.filter((word) => word === "et").length;
8282
console.log(result);
8383

8484
// Bonus 2
85+
86+
function checkPalindrome(phrase) {
87+
const phraseClean = phrase.toLowerCase().replace(/[^a-zA-Z]/g, "");
88+
let phraseCleanReverse = "";
89+
for (let i = phraseClean.length - 1; i >= 0; i--) {
90+
phraseCleanReverse += phraseClean[i];
91+
}
92+
if (phraseClean === phraseCleanReverse) {
93+
return true;
94+
} else {
95+
return false;
96+
}
97+
}
98+
99+
// console.log(checkPalindrome("Amor, Roma"));
100+
console.log(checkPalindrome("A man, a plan, a canal, Panama!"));

0 commit comments

Comments
 (0)