I want to upload random script files into a script tag element. I Have tried this but it didn't work.
var randomTest = Math.floor(Math.random() * 5) +1; //generating random number
var randomTestJs = "test" + randomTest + ".js"; // targeting random question file source
var questionSource = "js/" + randomTestJs; //selecting question file source
var test = document.querySelectorAll("script")[0]; //selecting tag attribute
test.setAttribute("src", questionSource); //overwriting question file
this can't work. the script tags are executed when the side will be loaded. you try to run the scripts on the fly. this is not the way it works.
perhaps you try to load your questions in a json format with fetch and than work with it.