I wanted to try to print elements of array (animals), so that each one of its elements be in new line (\n). Unfortunately, I couldn't manage to do it. Could someone solve that problem using the logic I have made inside console.log()? And yes, I would like single alert to show given message :)
let animals = ["fox", "elephant", "wolf"];
console.log("List of animals:");
for (let animal of animals) {
let itemNum = animals.indexOf(animal) + 1;
console.log(`${itemNum}: ${animal}`);
}
OUTPUT:
List of animals:
1: fox
2: elephant
3: wolf
Can someone think of a solution that would work for alert() as well?