0

Is there a much better way to write it using loops or a function ?

Heya Everyone and I am once asking for your help. I want to write the name of every single month using array.slice method but as I managed to write it name of every single month. I thought is there a way to write the name of every single month using loops or a function. So, Please help me Everyone. THANKS IN ADVANCE :) https://code.sololearn.com/Wy2EOMoZzhZw

16th Nov 2021, 10:54 AM
Manvendra Rajpoot
Manvendra Rajpoot - avatar
2 Answers
+ 8
//try this var months = ["January","February",...]; for (i =0;i<months.length;i++){ document.write(months[i]+","); }
16th Nov 2021, 11:05 AM
Simba
Simba - avatar
0
Alzy Welzy there is more easiest way to print month array https://code.sololearn.com/WD607555koy8/?ref=app What profit u are getting using this ?? 1. U can set your own lang without rewriting for each and every lang For example En , ar , it ...etc 2. U can get short form for month For example : long --> January short --> jan Without rewriting it twice 3. U are getting any array as return 😁
16th Nov 2021, 2:39 PM
Pariket Thakur
Pariket Thakur - avatar