Skip to content

Commit facd0c3

Browse files
committed
#4 - javaScript palindrome función
1 parent 67b0968 commit facd0c3

File tree

1 file changed

+13
-2
lines changed
  • Roadmap/04 - CADENAS DE CARACTERES/javascript

1 file changed

+13
-2
lines changed

Roadmap/04 - CADENAS DE CARACTERES/javascript/DobleDJ.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ for (let index = 0; index < message.length; index++) {
101101
- [] Isogramas
102102
*/
103103

104+
/**
105+
* Reverse a string
106+
* @param {string} word Any string word with symbols, spaces and string
107+
* @returns Returns reversed string word
108+
*/
109+
const reverseManual = (word) => word.split("").reverse().join("")
110+
104111
/**
105112
* Determine if two words are palindromes, anagram or isogram
106113
* @param {string} firstWord Any string word
@@ -109,7 +116,8 @@ for (let index = 0; index < message.length; index++) {
109116
*/
110117
function textAnalizer(firstWord, secondWord) {
111118
//TODO
112-
const resultPalindrome = palindromeTester(firstWord, secondWord)
119+
if (palindromeTester(firstWord, secondWord)) console.log("Las palabras son palíndromes")
120+
113121
const resultAnagram = anagramaTester(firstWord, secondWord)
114122
const resultIsogram = isogramaTester(firstWord, secondWord)
115123
}
@@ -120,7 +128,10 @@ function textAnalizer(firstWord, secondWord) {
120128
* @param {string} secondWord Any string word
121129
* @returns Returns a boolean response true or false
122130
*/
123-
const palindromeTester = (firstWord, secondWord) => {}
131+
const palindromeTester = (firstWord, secondWord) => {
132+
//TODO reversed secondWord check firstWord
133+
return firstWord.toLowerCase() === reverseManual(secondWord).toLowerCase()
134+
}
124135

125136
/**
126137
* Determine if two words are anagram

0 commit comments

Comments
 (0)