The basic code solution is said to perform poorly when larger strings are passed to the function, and that the advanced code solution is the most performant of the three solutions given. However, when comparing the two different solutions in the console in Chrome, it seems the basic code solution actually performs better.
I ran both solutions on a palindrome that is 2709504 characters long. There are no special characters in this string, it’s simply the words “helloworld” repeated over and over again with no spaces in between.
I used the following code to measure the time each solution took to run:
var t0 = performance.now(); palindrome(longString); var t1 = performance.now(); console.log("Solution took " + (t1 - t0) + " milliseconds.")
And for me, the basic solution completes in about half of the time that the advanced solution does. For the 2709504 character long string I mentioned about, the basic solution takes on average about 251.500ms and the advanced solution takes 640.800.
Does anyone know why this would be the case? Has anything changed since the challenge guide was written?