I'm creating an extension that requires copying to clipboard, but I don't want to have 18 different functions that do (pretty much) the exact same thing.
This is the function that I wrote:
function copyS1_1() {
var letter_to_copy = document.getElementById('textarea-S1-1');
letter_to_copy.select();
navigator.clipboard.writeText(letter_to_copy.value);
}
function copyS1_2() {
var letter_to_copy = document.getElementById('textarea-S1-2');
letter_to_copy.select();
navigator.clipboard.writeText(letter_to_copy.value);
}
Each function is called 'copyS#_#' for 'Section' then the number in that section. I don't want to have 18 of these, so I'm looking for a way to simplify it down to 3 functions (one for each Section, there's 3.)