title: String Pattern Question - Core Java (repeatSeparator)
body: <p><strong>Write a Java function such that Given two strings, word and a separator, return a big string made of count occurences of the word, separated by the separator string.</strong></p>
  
  <pre><code>repeatSeparator("Word", "X", 3) → "WordXWordXWord"        
  repeatSeparator("This", "And", 2) → "ThisAndThis"         
  repeatSeparator("This", "And", 1) → "This"        
  </code></pre>
  
  <p>My code is as below but is not working</p>
  
  <pre><code>public String repeatSeparator(String word, String sep, int count) {        
      if(count == 1) {       
          return word;        
      }    
      if(count &gt; 1) {       
          for (int i = 0; i &lt; count-1; i++){        
              word = word + sep + word;           
          }       
      }               
     return word;                         
  }
  </code></pre>
  
  <p>Example Output ::    </p>
  
  <pre><code>                                   Expected         Run                  Result        
  repeatSeparator("Word", "X", 3) → "WordXWordXWord" "WordXWordXWordXWord" X    
  </code></pre>