i made a button called btn and i gave it a text
btn = document.createElement('button')
btn.textContent = "Hello World"
i want to make it alert its textContent when it gets clicked.
i know i can use:
btn.onclick = function(){alert(this.textContent)}
but lately i have learnt about these arrow functions and i wanted to use it here so i made this
btn.onclick = ()=>{alert(this.textContent)}
and
btn.onclick = ()=> alert(this.textContent)
but both of them alert undefined
so how can i make it ?