So... this is a bit hard to explain, but I want to print with Javascript this result:
- The '*' character has to be random. SO everytime the page loads, there is a new character randomly exposed inside of my loop. Is it possible? Does anyone have an idea how to get there?
I manage to generate a random function with different characters but they are printing in all rows and always in the same place. What do I have to do to make sure that a random character is printed only once and in a random row every time?
My code:
const characters = '&%$*';
function generateRandomCode() {
let result = ""
let charactersLength = characters.length;
for (let i = 0; i < 1; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result
}
let string = "";
for (let i = 1; i <= 5; i++) {
for (j = 1; j <= 5; j++) {
string += "#";
}
string += generateRandomCode();
generateRandomCode();
string += "<br>";
}
document.write(string);
This is what my code prints:

