Q:

Create list dynamically from array javascript

I need to create a list from an array. 
I pass an input value and recreate the list with all the matches I found.
if there's no match I need to show the "no results" message.

inputValue = "Ja" returns Jack and Jake
inputValue = "Jak" returns Jake
inputValue = "foo" returns "No results"

var arr = [{"name": "Jack"}, {"name": "Jake"}];
var txtName = document.querySelector("#txtName");

txtName.addEventListener('keyup', function(e){
  arr.forEach(function(item){
    if(item.name.toLowerCase().indexOf(txtName.value) > -1){
        myList.innerHTML +=
        `<li>${item.name}</li>`
        return
      }else{
        myList.innerHTML = `<li>No results </li>`
      }
  });
});
<input type="text" id="txtName">
<ul id="myList"></ul>

A:

You should only decide to output "No results" at the end of the loop. You cannot know whether it is appropriate to output this at some arbitrary iteration of the loop, so you are wiping out good results that might already have been output.
Here is a corrected version:

var arr = [{"name": "Jack"}, {"name": "Jake"}];
var txtName = document.querySelector("#txtName");

txtName.addEventListener('keyup', function(e){
    var lowText = txtName.value.toLowerCase();
    var matches = arr.filter(function(item){
        return item.name.toLowerCase().indexOf(lowText) > -1;
    }).map(function (item) {
        return `<li>${item.name}</li>`;
    }).join('');
    myList.innerHTML = matches || `<li>No results </li>`;
});
<input type="text" id="txtName">
<ul id="myList"></ul>

If you want an empty input to give "No results" instead of all items, then change the definition of matches to:
var matches = lowText.length && arr.filter( // ...etc

