I am trying to make a function which takes a characters and makes a button with the character inside it. Here's what I have so far:
function keyButton(char) {
var btn = document.createElement("button"); //create button
btn.innerText = char; //fill it with char
return btn;
}
var button = keyButton("a"); //use keyButton to fill buttons with characters
document.appendChild(button);
This however doesn't seem to work, any help would be appreciated.


documentis probably the issue. Trydocument.body.appendChild(button);maybe.document.body.appendChild(button);works fine, I was just not calling the script in the body. Thanks!