title: How to pass values into not created function
body: <p>I have a question how to pass value into function inside a <code>forEach</code> template string. As you can see in my code <code>forEach</code> loop is creating html card element with button inside. I only idea i have is to create onclick in html but i know this is <strong>not acceptable</strong>. Could you please help how to solve this problem. I mean how to pass this value without maiking onclick inside of html element.</p>
  
  <p>thanks</p>
  
  <pre><code>let searchInput = document.getElementById('search');
  
  class fetchData {
  
      constructor() {
          this.apiKey = ''
      }
  
      async getMovies(movie) {
          const movieRes = await fetch(`http://www.omdbapi.com/?apikey=${this.apiKey}&amp;s=${movie}`)
          const moveData = await movieRes.json()
          return {
              moveData
          }
      }
  }
  const fetchMovie = new fetchData
  
  searchInput.addEventListener('keyup', (e) =&gt; {
      let input = e.target.value;
  
      if (input !== '') {
          fetchMovie.getMovies(input)
              .then(res =&gt; {
                  let data = res.moveData.Search
  
                  if (!data) {
                      return false
                  } else {
                      let output = ''
                      data.forEach(movie =&gt; {
                          let poster
                          if (movie.Poster === "N/A") {
                              poster = `https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg`
                          } else {
                              poster = movie.Poster
                          }
                          output += `
  
                      &lt;div class="card"&gt;
                      &lt;img class="card-img-top" src="${poster}" alt="Card image cap"&gt;
                      &lt;div class="card-body"&gt;
                        &lt;h5 class="card-title text-left"&gt;${movie.Title}&lt;/h5&gt;
                        &lt;p class="card-text text-left"&gt;${movie.Year}&lt;/p&gt;
                        &lt;a href="#" class="btn btn-primary" onclick="getID('${movie.imdb}')"&gt;Get details&lt;/a&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                      `
                      });
                      document.getElementById('container').innerHTML = output;
                  }
              })
              .catch(err =&gt; console.log(err))
      }
      e.preventDefault();
  })
  
  function getID(id) {
      sessionStorage('movieID', id)
  
  }
  </code></pre>