i'm a newbie starting to learn java-script..
const textchanger = function () {
let text = "text that has been changed now"
const picktext = function () {
let element = document.querySelector("h1")
element.textContent = text
return {
callfun: function () {
picktext();
console.log(text);
}
}
}
}
textchanger.fun()
<h1> Getting started </h1>
i'm trying to change the text inside
<h1>Getting started</h1>
but getting the error..
TypeError: textchanger.callfun is not a function at Object.
TextChanger is the function not a plain variable so below code works: