I am currently tackling my initial JavaScript assignment which involves the task of creating a function that accepts an array of strings as its parameter and outputs the first letter of each element individually on separate lines. The unique requirement is to utilize a FOR OF loop, function, and charAt() method for this task. The expected output should be: H, W, T, I, M, S; with each letter appearing on a distinct line. My struggle lies in understanding how to achieve this without resorting to using the toString.charAt method, as specified by the instructions. Moreover, I am uncertain about whether the FOR OF loop should contain the function or if the function should encompass the loop. Having commenced learning JavaScript just last week, I find myself quite perplexed. Any guidance offered would be greatly appreciated.
let arr = (["Hello", "World", "This", "Is", "My", "String"]);
// mandatory use of for of
for (let element of arr) {
console.log(element.toString())
}
// necessary function
let myFunction = (element) => element.charAt(0);
myFunction(arr)
// required charAt
var str = new String( "This is string" );
console.log( arr.toString().charAt(0));
console.log( arr.toString().charAt(6));
console.log( arr.toString().charAt(12));
console.log( arr.toString().charAt(17));
console.log( arr.toString().charAt(20));
console.log( arr.toString().charAt(23));