html
<input type="text" id="input-el" />
    <button id="input-btn">SAVE INPUT</button>
    <script src="index.js"></script>
javascript
let myleads = [];
const inputEl = document.getElementById("input-el");
let inputBtn = document.getElementById("input-btn");
inputBtn.addEventListener("click", function () {
  myleads.push("www.awsomelead.com");
    console.log(myleads);//giving the output
  
});
console.log(myleads);//not giving the output
see here when i do "console.log(myleads);" outside the function i'm not getting the output but when i put "console.log(myleads);" inside the function i'm getting the output. my question is why "console.log(myleads);" is not working outside the function??
 
    