Bug or Error in Palindrome Checker

**A bug or error **

I find the logic to check for palindrome correct , the code runs perfectly on repl.it for all the test cases as run on fcc , I don’t know why it gives
“TypeError: unknown: Cannot read property ‘0’ of undefined”

Your code so far

function palindrome(str) {
  // Good luck!
  let nstr="";
  for(let i=0;i<str.length;i++)
  for(let j=0,k=nstr.length-1;j<k;j++,k--)
    if(nstr[j] !== nstr[k])
      return false;
  return true;


I didn’t use slice , reverse , join purposely

Link to the challenge:

your if statements and your for loop haven’t got any curly braces this is most likely the cause of the typeError