- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 06:41 AM
How to find the position of an element in an array?
Example:
var array = [1,2,3,4,5,6,7,8,9,10,11];
I have to find the position of element '5' in above array.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 06:43 AM
hello ,
you can try this
var array= [1,2,3,4,5,6,7,8,9,10,11];
var position = array.indexOf(5);
Hope this helps
Mark the answer correct if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2023 07:18 AM
I hope you can help me out here. I have the reverse need. I need to find the element in a certain position.
Ex.
var array = [apple, lemon, banana]
How do I find and store the value in position 3 (banana)?
Thanks.