
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
JavaScript Array showing the index of the lowest number
We are required to write a JavaScript function that takes in an array of numbers. Then the function should return the index of the smallest number in the array.
Example
The code for this will be −
const arr = [3, 56, 56, 23, 7, 76, -2, 345, 45, 76, 3]; const lowestIndex = arr => { const creds = arr.reduce((acc, val, ind) => { let { num, index } = acc; if(val < num){ num = val; index = ind; }; return { num, index }; }, { num: Infinity, index: -1 }); return creds.index; }; console.log(lowestIndex(arr));
Output
The output in the console −
6
- Related Articles
- Highest and lowest value difference of array JavaScript
- Finding the index position of an array inside an array JavaScript
- Highest and lowest in an array JavaScript
- Return the lowest index in the string where substring is found using Python index()
- Returning the first number that equals its index in an array using JavaScript
- Pair of (adjacent) elements of an array whose sum is lowest JavaScript
- Return the lowest index in the string where substring is found in a range using Python index()
- Find closest index of array in JavaScript
- Finding median index of array in JavaScript
- Get the index of the nth item of a type in a JavaScript array
- Reverse index value sum of array in JavaScript
- Sort by index of an array in JavaScript
- Sorting digits of all the number of array - JavaScript
- JavaScript Return the lowest index at which a value should be inserted into an array once it has been sorted (either in ascending or descending order).
- Finding the nth power of array element present at nth index using JavaScript

Advertisements