title: Use Variable from for function in another js file
body: <p>i want to use a variable from an other js file but when i use the import and export statement that dont work because that say {file} is not defined.
  And my problem is my variable is in a function, and in a loop for.
  i think i'm doing it wrong but could you help me ?</p>
  <p>here is the code on my fabric.js</p>
  <pre><code>    const initCanvas = () =&gt; (                                  
      new fabric.Canvas('canvas', {
          preserveObjectStacking:true,
          height: 450,
          width: 600,
          backgroundImage: {file}, &lt;--- i want to use the variable &quot;file&quot; here 
          
      })
  )  
  </code></pre>
  <p>and in my emil.js i have a function with this code</p>
  <pre><code>  DisplayCategory(category) {  
         (...)             //Function that generate te list of 
      else {                                          //Generate the product list of a category (ex : product[2][x])
          let product = [];
          let x = findProduct(product_array, selected_product);
          for (let y = 1; product_array[x][y]; y++) {
              var ext = &quot;.jpg&quot;;
              var file = '/' + product_array[x][y] + ext; &lt;--- file is defined here
              product.push(
                  &lt;Card style={{ width: '18rem' }} className={this.takeClass(product_array[x][y])} onClick={() =&gt; this.HandleOnClick(product_array[x][y], 2)}&gt;
                      &lt;Card.Img variant=&quot;top&quot; src={file} /&gt; &lt;--- and is used here
  </code></pre>
  <p>The function is to long so i dont have put the rest</p>