It is possible to use a recursive function to make nested for loops , I have tried many things but all of them gave me an error.
for (let a of p) {
for (let a of p) {
for (let a of p) {
for (let a of p) {
for (let a of p) {
for (let a of p) {
for (let a of p) {
for (let a of p) {
}
}
}
}
}
}
}
}
// Reducirlo a:
function rep() {
for (let a of p) {
rep();
}
}
for (let a of p) {
rep();
}
You can use recursion without problems. In this example that I give you, you go through the array
p
as many times as indicated by the exit condition (in this case it would be that you have counted 10 sheep) and calling the same functionrep()
:It is important to control the exit condition well so as not to cause infinite loops... and thus have sweet dreams :)