2

['zero','one','two','three','four','five','six','seven','eight','nine'] I want to search for an element with index 4 in the array above. So 4 should return the word "four" because it is at index four. Please help.

1 Answer 1

2

You would simply use bracket notation like so:

var array = ['zero','one','two','three','four','five','six','seven','eight','nine'];

console.log(array[4]);

The above snippet outputs 'four' to the console. For more information, see MDN's Property accessors page.

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

2 Comments

Thank you. @Travis
No problem. If this is a satisfactory answer, go ahead and mark it answered.

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.