[SOLVED] Problem palindrome exercise | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] Problem palindrome exercise

Hi, it's the first time that I post something here and i'm sorry for eventual mistakes. I have a problem with this code. I have to check if the user word is a palindrome but i don't know where is the error. Thank you to everyone https://code.sololearn.com/WkO05PjnwLWU/?ref=app

25th Apr 2020, 3:48 PM
Ghost11
Ghost11 - avatar
13 Answers
+ 2
https://code.sololearn.com/WvjU9061g2rC/?ref=app
28th Apr 2020, 8:18 PM
Mwikisa Kapesa Lufungulo
Mwikisa Kapesa Lufungulo - avatar
+ 1
Jayne Clifford-Greening yeeeeah, thanks for telling me!!! Finally it worked :) :)
26th Apr 2020, 2:17 PM
Ghost11
Ghost11 - avatar
+ 1
Ghost11 - you're welcome. Well done. Jayne 🐱
26th Apr 2020, 2:22 PM
Jayne Clifford-Greening
Jayne  Clifford-Greening - avatar
+ 1
Mwikisa Delton Kapesa Lufungulo thank you, in this way i learned another method
28th Apr 2020, 11:04 PM
Ghost11
Ghost11 - avatar
0
Ghost11 we are happy to help you but you have not yet understood that Java and JavaScript are two different languages. You have written JS code in Java. That's really a significant mistake and I would like you to do some research and get back on the right track.
25th Apr 2020, 4:18 PM
Avinesh
Avinesh - avatar
0
Hi, thank you, I included the code and I forgot to write that the code is javascript
25th Apr 2020, 4:21 PM
Ghost11
Ghost11 - avatar
0
Ghost11 you can write the code in web. It's on the top when you select a language to write your code. It has a JS section where you can put that code and test it. If you still find difficulty, you can come back with your code.
25th Apr 2020, 4:23 PM
Avinesh
Avinesh - avatar
0
Avinesh Thanky you, I rectified the code in the answer.
25th Apr 2020, 4:38 PM
Ghost11
Ghost11 - avatar
0
you must start your loop at index = user_word.length-1 (for n length string, indexes start at 0 and end at n-1 ^^) for (var i = user_word.length-1; i >= 0 ; i--) You could have debugged it by yourself, just by adding a console.log of the result variable (wich was outputing "undefinedanna" before the fix ;))
26th Apr 2020, 2:59 AM
visph
visph - avatar
0
visph thank you, I was going crazy to solve this exercise. You saved my mind :) :)
26th Apr 2020, 9:39 AM
Ghost11
Ghost11 - avatar
0
Hi, I entered the name Hannah and the result told me it was a palindrome! Jayne 🐱
26th Apr 2020, 2:08 PM
Jayne Clifford-Greening
Jayne  Clifford-Greening - avatar
0
I also entered the name Julie and was told it wasn't a palindrome! Jayne 🐱
26th Apr 2020, 2:09 PM
Jayne Clifford-Greening
Jayne  Clifford-Greening - avatar
0
Ghost11 You are welcome
29th Apr 2020, 10:14 PM
Mwikisa Kapesa Lufungulo
Mwikisa Kapesa Lufungulo - avatar