0

The only difference is brackets in the second loop. Its for checking if a given string is a palindrome.

function solution(str) {
    
    var len = Math.floor(str.length / 2);
    for (var i = 0; i < len; i++)
        if (str[i] !== str[str.length -i -1]) 
            return false;
            return true;
        
    
  /*var len = Math.floor(str.length / 2);
  for (var i = 0; i < len; i++){
    if (str[i] !== str[str.length - i - 1]) {
      return false;
    } else {
  return true;
    }
  }*/

} 

0 Answers0