
- 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
Get minimum number without a Math function JavaScript
We have to write a function that takes in n Number literals as argument, where n is any whole number and returns the smallest number of those numbers without using any library function.
We will solve this problem via a while loop and the code for this will be −
Example
const numbers = [12, 5, 7, 43, -32, -323, 5, 6, 7, 767, 23, 7]; const findMin = (...numbers) => { let min = Infinity, len = 0; while(len++ < numbers.length){ min = numbers[len] < min ? numbers[len] : min; } return min; }; console.log(findMin(...numbers));
Output
The output in the console will be −
-323
- Related Articles
- Math. fround() function in JavaScript
- Math. hypot() function in JavaScript
- Check for perfect square without using Math libraries - JavaScript
- JavaScript: How to Find Min/Max Values Without Math Functions?
- Implementing Math function and return m^n in JavaScript
- Converting number of corresponding string without using library function in JavaScript
- JavaScript Math Object example
- What are JavaScript Math Functions?
- JavaScript Number Function
- Fetch Second minimum element from an array without sorting JavaScript
- What is math object in JavaScript?
- Square root function without using Math.sqrt() in JavaScript
- How to perform square root without using math module in Python?
- What is Math Object in JavaScript Program?
- PHP – How to set or get the default scale parameter for all bc math functions using bcscale() function?

Advertisements