I'm making a calculator table with javascript, and I'm writing document.getElementById('x').innerHTML all the time. Can I write a function to replace this code? For example:
function select (a) {
return document.getElementById(${a}).innerHTML;
}
The trouble I see is if I used template literals within getElementById, I can't add the quotes necessary to define the string as a string.
To put it back into context, I have many cells in a table each with different Ids. In order to allow js to update each cell, I've had to repeatedly write: document.getElementById('x').innerHTML. This had me wonder, can I just write a little function that would let me skip this extra typing? Can a function take an argument and return it with quotes around it?