Could someone help me solve this problem with javascript? Palindrome Check: Write a function to check if a string is a palindrome. he's number 3 on this list -

HuntressHimbo, (edited )

Hi, I don’t think giving you the answer directly will help you learn it, but I can give you some general tips for this.

First here is the MDN documentation for the string type:…/String

On the left hand side you should see a column with methods the string type contains. You can use several of these to accomplish a palindrome check. String.slice(), String.charAt(),, String.match(), and String.substring() are all methods that you can use to write your check.

In addition to those, I would recommend looking at String.toLowerCase()/String.toUpperCase() to avoid issues with capitalization, and String.trim() to avoid trailing or leading whitespace.

Also you will need a variable to store your result, my general recommendation is to start this variable as true and set it to false when you detect any inconsistency, and probably one to store the index you are currently checking. Last little tip is that many String methods accept negative indices to count from the end rather than from the start. Good luck!

One more giant tip because I don’t know what your experience with JavaScript is, but pay attention when comparing that you don’t use == when you should use === and vice versa. The difference is that == will try to coerce the values to the same type before comparison, which can lead to.unintuitive behavior


thanks for the tip


A str is a list of characters. Just reverse it and check if it’s the same.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • javascript
  • khanakhh
  • magazineikmin
  • mdbf
  • GTA5RPClips
  • everett
  • rosin
  • Youngstown
  • tacticalgear
  • slotface
  • ngwrru68w68
  • kavyap
  • DreamBathrooms
  • thenastyranch
  • tester
  • JUstTest
  • ethstaker
  • cubers
  • osvaldo12
  • cisconetworking
  • Durango
  • InstantRegret
  • normalnudes
  • Leos
  • modclub
  • anitta
  • provamag3
  • megavids
  • lostlight
  • All magazines