-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exercise forwards and backwards. #6
Comments
Hi Zach,
you're calling the method palindrome() on the string "test", so this is set to "test". So when you write
you're getting the length of "test" (4) subtracting 1 and getting 3 (which isn't actually the length, it's the index of the last character in the string). Then in the for loop, we're using Hope that makes sense! |
Hi Beth, Thanks so much for your reply. That part makes sense we are grabbing the last character of the string. When we use the for loop how is it iterating through each character in the len variable if we are only grabbing the last character in the string? When we compare the charAt(i) != this.charAt(len-i) is len-i doing the oppostite? is it now grabbing the first character? but how does it iterate through all the characters if we are only iterating through the len variable which is only getting the last character?
|
Hi Zach, Beth |
Hi Beth, I finally got it. Took my time with this exercise and worked through the loop on paper to have it finally set in. Thank you again for taking the time to answer questions. Cheers! |
Hi,
I am doing the final exercise for matching words forwards and backwards.
Curious about this line
When I try to do lexical scope as I walk through this exercise I am stumped as to how this variable gets the length. When I read this it seems that it is getting the length minus one character or this is getting the reversed order. Am I reading this correctly?
The text was updated successfully, but these errors were encountered: