I have the following JSFiddle which is printing letters from A to H.
const alphabet = Array.from({length: 8}, (x, i) => String.fromCharCode(65 + i));
function printEach(arr) {
if (arr.length === 0) return; // If arr is empty, return
console.log(arr.shift()); // Remove the first letter from arr and print it
return printEach(arr); // Deal with the remaining elements
}
printEach(alphabet);
If I want to repeat printing letters from A-H starting . I have a loop going on in my code (not shown anywhere in this post)which is making an index available to me from 1-96 and
for the value 0, I want to print A,
for the value 1, I want to print B,
for the value 2, I want to print C,
for the value 3, I want to print D,
for the value 4, I want to print E,
for the value 5, I want to print F,
for the value 6, I want to print G,
for the value 7, I want to print H,
for the value 8, I want to print A,
for the value 9, I want to print B,
so on and so forth …
for the value 95, I want to print H (I believe H will be the 96th value but I may be wrong).
I am wondering if it’s possible to modify my function in such a way I can handle above scenario?