I wrote this script to add elements to the DOM according to content stored in an array, then I added a listener on a click event to those elements.
It works, but I am pretty sure it can be improved, any idea?
function writeSuggestions() {
  for (var k = 0; k < suggestions.length; k++) {
    citySample.innerHTML += "<li>" + suggestions[k][0] + "</li>";
  }
  for (var i = 0; i < citySample.children.length; i++) {
    (function(index){
      citySample.children[i].onclick = function(){
        lat = suggestions[index][1];
        lng = suggestions[index][2];
      };
    })(i);
  }
}
Thank you in advance
