New course! Every coder should learn Generative AI!
Try a free lesson0
How to output from a loop in the form of arrays
I need to know how to output data from loop codes in the form of arrays . It may sound simple but it's really giving me a headache. Help will be much appreciated 🙏
1 Answer
+ 4
Do you want to output each element in a single line?
x = [4, 3, 2, 1];
x.forEach(function(el) {
console.log(el);
})
Or in a single line?
console.log(x);
(Here you wouldn't need a loop?)