1

i want start index value from 1 not 0

{props.useraccountListData.useraccountTypeList.map((item, index) => (
{index}
))}

The output is start from 0 1 2

But i want start from 1 2 3..

3

2 Answers 2

3

just use {index + 1} inside your loop

Sign up to request clarification or add additional context in comments.

Comments

1

The index in JavaScript always starts at 0 and this cannot be changed. The only way to remedy this is to write index + 1 when you output. This assumes you wish to loop through all items.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.