Unable to reverse all the characters in the below code along with spaces : The code below reverses all the characters in a sentence.But it is unable to do so.This is a kid stuff but at this moment it's not compiling.Can anyone figure out the issue
Let's say: "Smart geeks are fast coders".The below code should reverse as following: "trams skeeg era tsaf sredoc"

            function solution(S) 
            {   
            var result = false;
            
            if(S.length === 1)
            
            {
             
            result = S;
   
            }

           if(S.length > 1 && S.length < 100)
    
           {
        
           var wordsArray = S.split(" ");
   
           var wordsCount = wordsAray.length;
   
           var reverseWordsString = '';
   
           for(var i=0; i<wordsCount; i++)
   
          {
            
            if(i > 0)
           
          {
         
         reverseWordsString = reverseWordsString + ' ';
         
            }
         
      reverseWordsString = reverseWordsString + wordsAray[i].split("").reverse().join("");
        
           }
        
         result = reverseWordsString;
    
           }
    
    return result;
     
      }
