Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript find smallest number in an array

const arr = [14, 58, 20, 77, 66, 82, 42, 67, 42, 4]
const min = Math.min(...arr)
console.log(min)
Comment

find lowest number in array js

const arr = [1,2,3,4,5]
console.log(Math.min(...arr)) // 1
Comment

find smallest number in array js

//Not using Math.min:
const min = function(numbers) {
  let smallestNum = numbers[0];
for(let i = 1; i < numbers.length; i++) {
    if(numbers[i] < smallestNum) {
      smallestNum = numbers[i];   
    }
  }
return smallestNum;
};
Comment

find smallest length string in an array js

var arr = ["aaaa", "aa", "aa", "aaaaa", "a", "aaaaaaaa"];

console.log(
  arr.reduce((a, b) => a.length <= b.length ? a : b)
)
Comment

Find smallest Number from array in javascript

function smallestElemnts(numbers) {
    var smallest = numbers[0];
    for (let i = 0; i < numbers.length; i++) {
        var elements = numbers[i];
        if (elements < smallest) {
            smallest = elements;
        }
    }
    return smallest;
}
const numbers = [2, 3, 4, 8, 5, 2, 4];
console.log(smallestElemnts(numbers));
//Output: 2
Comment

how to find the smallest two numbers in an array javascript

function sumTwoSmallestNumbers(numbers) {  
  numbers = numbers.sort((a, b) => {
    return a - b; });
};  //this will turn the numbers list into the 2 lowest numbers
Comment

js math function that returns smallest value

console.log(Math.min(2, 3, 1));
// expected output: 1

console.log(Math.min(-2, -3, -1));
// expected output: -3

const array1 = [2, 3, 1];

console.log(Math.min(...array1));
// expected output: 1
Comment

find smallest number in array javascript using for loop

const array = [320, 52, 532, 920, 20];
let smallestNum = array[0];
for (let i = 1; i < array.length; i++) {
  if (array[i] < smallestNum) {
    smallestNum = array[i];
  }
}
console.log(smallestNum);
Comment

how to find smallest number in array js

Array.min = function( array ){
    return Math.min.apply( Math, array );
};
Comment

find smallest number in an array

static int SmallestNumberin(int[] numbers){
            int smallestNumber = numbers[0];
            for (int i = 1; i < numbers.Length +1; i++)
            {
                if(numbers[i] < smallestNumber){
                    smallestNumber = numbers[i];
                }
            }
            return smallestNumber;
        }
Comment

find smallest length string in an array js

var arr = ['cats', 'giants', 'daughters', 'ice'];
var min = Math.min(...arr.map(({ length }) => length));
console.log(min);
Comment

find the smallest number from an array

// smallest number from array
function solution(num) {
  let small = num[0];
  for (let i = 1; i <= num.length; i++) {
    if (small > num[i]) {
      small = num[i]
    }
  }
  console.log("smallest nunber:", small)
}
solution([3, 1, 4, 6, 5, 7, 3, 2,0,-1])
Comment

Find Smallest Number by function in Javascript

function smallestNumber(first, second, third) {
    if (first < second && first < third) {
        return first;
    } else if (second < first && second < third) {
        return second;
    } else {
        return third;
    }
}
const num1 = 100;
const num2 = 120;
const num3 = 80;
console.log(smallestNumber(num1, num2, num3));
//Output: 80
Comment

get smallest value in array js

var test=[1, 2, 4, 77, 80];
console.log("Smallest number in test: "+Math.floor(Math.min(test)));
Comment

Get the Smallest Element of an Array, array js

const getSmallest = (arr) =>
  arr.reduce((smallest, num) => Math.min(smallest, num));
const arr = [13, 7, 11, 3, 9, 15, 17];
console.log(getSmallest(arr)); // 3
Comment

javascript smallest integer of a number

Math.ceil(num);
//The ceiling of num: the smallest integer greater than or equal to num
Comment

js get smallest value of array

Array.min = function( array ){
    return Math.min.apply( Math, array );
};
var minimum = Array.min(array);
Comment

PREVIOUS NEXT
Code Example
Javascript :: arry to object using reduce 
Javascript :: JavaScript Split the string into an array of characters 
Javascript :: this.handler.handle is not a function 
Javascript :: my vscode does not recognize react code syntax 
Javascript :: react bootstrap col not working 
Javascript :: jquery select all checkboxes except disabled 
Javascript :: how to access css and js with nodejs 
Javascript :: onsubmit in js 
Javascript :: convert camelCase letter to Sentence case 
Javascript :: angular timeout function 
Javascript :: node-fetch 
Javascript :: usehistory hook 
Javascript :: js for in 
Javascript :: how to get the all input element id value 
Javascript :: js UTC to local timezone 
Javascript :: node.js function 
Javascript :: tostring() javascript 
Javascript :: farewell discord.js 
Javascript :: jquery selector id ends with 
Javascript :: js comparison operators 
Javascript :: usememo react 
Javascript :: javascript mod 
Javascript :: js get all arguments from function 
Javascript :: callback function js 
Javascript :: javascript promise.all 
Javascript :: regular expression in elastic 
Javascript :: angular radio box already showing checked 
Javascript :: axios post nuxt 
Javascript :: javascript date double digit month 
Javascript :: Expected a JavaScript module script but the server responded with a MIME type of "text/html" 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =