title: Javascript, onclick, Uncaught ReferenceError: FAVOURITES is not defined
body: <p>I have an <code>Uncaught ReferenceError: FAVOURITES is not defined(onclick)</code>, i don't understand where is my sintax error in <code>button.setAttribute("onclick", "ContactLoader.table(" + table +")");</code>. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ContactLoader.table =
   function(table){
    ContactLoader.CURRENT_PATTERN = null;
    ContactLoader.CURRENT_TABLE = table;
    ContactLoader.CURRENT_LETTER = "A";
    ContactLoader.loadData();
   }
  
  function generateSearchLetter(){
   
   var divSearch = document.getElementById("search");
   if(divSearch.lastChild.id === "search_name");
    divSearch.removeChild(divSearch.lastChild);
   
   var divSearchLetter = document.createElement('div');
   divSearchLetter.setAttribute("id", "search_letter");
   divSearch.appendChild(divSearchLetter);
   
   
   var divAllFav = document.createElement('div');
   divAllFav.setAttribute("class", "search_all_favourites");
   divSearchLetter.appendChild(divAllFav);
   
   var arr1 = new Array("ALL","FAVOURITES");
   
   for(var i=0; i&lt;2; i++){
    
          var button  = document.createElement('div');
    
    var textNode = document.createTextNode(arr1[i]);
    button.appendChild(textNode);
    var table = button.textContent;
    
    button.setAttribute("class" , "letterAF");
    button.setAttribute("onclick", "ContactLoader.table(" + table +")"); 
    
    
    divAllFav.appendChild(button); 
   }
  }</code></pre>
  </div>
  </div>
  </p>