2

How to print the index number like this?

Array[0] = Yasir
Array[1] = Ahmed
Array[2] = Yousuf

enter image description here

2
  • 1
    arr.map((element, idx) => `Arrax[${idx}] = ${element}`).join('\n') Commented Oct 26, 2019 at 20:11
  • Please copy-paste the expected output into the question and use the {} 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. Commented Oct 27, 2019 at 0:32

1 Answer 1

2

If you have data as an array of names, this will work for you:

arr.map((El,index) => `Array[${index}]-${el}`))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.