How to print the index number like this?
Array[0] = Yasir
Array[1] = Ahmed
Array[2] = Yousuf
J. Murray
1,45011 silver badges19 bronze badges
1 Answer 1
If you have data as an array of names, this will work for you:
arr.map((El,index) => `Array[${index}]-${el}`))
answered Oct 26, 2019 at 20:11
cuddlemeister
1,81516 silver badges18 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
arr.map((element, idx) => `Arrax[${idx}] = ${element}`).join('\n'){}button in the question editor toolbar to format it as code, if appropriate. Do not post images that represent text when the text can be posted instead.