0

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 🙏

14th Aug 2021, 7:31 PM
Moses Uga
Moses Uga - avatar
2 Answers
+ 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?)
14th Aug 2021, 7:56 PM
Lisa
Lisa - avatar