Good day. Please help me figure it out. The task is as follows: There is a button for adding the object ID to the print, the ID is dynamically substituted.
<a class="waves-effect waves-light btn" onclick="addPrint(48)"> <i class="material-icons left">print</i> В печать </a> When you press a button, the ID is passed to the function:
function addPrint(id){ var idToPrint = []; return function pushId(){ return idToPrint.push(id); }; } I try to make it so that all these IDs are saved in the idToPrint = [] array, so that I can work with them in the future, print via another function. As I understand it, implement it correctly without global variables, through closures.
What does not work: to check whether the values are stored in idToPrint or not, and how correctly then to "pull" this array from there?
Thanks in advance.