JS Interview #9: Find the Largest & Smallest Elem in an Array in JavaScript

preview_player
Показать описание
Welcome, we will see how to find the Largest & Smallest Elem in an Array in JavaScript in just one line of code.

😊 Become a Member, get access to perks, free Source code, & more..

************* 😍 Must Watch Videos For Web Development 😍 *************

Рекомендации по теме
Комментарии
Автор

Console.log(Math.min(…arr));
Thats it you we will get the minimum number 👍

SubhamKumar-lzbt
Автор

Can u make on video how to find 2 largest number in array without sort & with sort also

keshavagarwal
Автор

Or we can sort an array in descending order and then return the first element which will be maximum Element.

ashurajput
Автор

Hello Thapa, we want to learn how a paytm gateway is integrated in website using node js and react. Please make a video on how paytm gateway is integrated.
we will very thankfull to you

jasmindersingh
Автор

Vinod bhai if we can use Math.max(...arr) and Math.min(...arr), and then return the values, then also we can get the result..but will it affect our impression on interviewer?

Adarshabinash
Автор

salam sir me apki React Ecommerce Website ki class lara ho sir meri 20 video chal ri hai to sir aus me ak masla hara hai ka jo apki API ka link hai wo mera code aus ko saamj nahe hara hai or wo website pa api nahe chala ra hai ro sir kouch guide karday me kia karru

syedshahab
Автор

Data structure algorithm video needeeed🔥🔥

mr.dramas
Автор

sir please restart ecommerce site using mern and add authentication and payment gateway.
Currently i am working on my mern stack project but while connecting react with node i get several error.

tusharadhikari
Автор

Awesome could you please make videos on DSA, your videos are very helpful to easily understood ❤️❤️

vrb
Автор

const arr = [12, 3, 5, 89, 1];
let min = arr[0];

for(let i=0; i<arr.length; i++) {
if (arr[i] > arr[i+1]) {
min = arr[i+1]
}
}
console.log(min);

SuhailGour-zwjn
Автор

const arr = [12, 3, 5, 89, 1];

let sum = arr.reduce((a, b)=>{
return a < b ? a : b
})

let sum2 = arr.reduce((a, b)=>{
return a > b ? a : b
})

console.log(sum)
console.log(sum2)

chandreshkumar
Автор

const arr = [12, 3, 5, 89, 1];

let SmallestNo = Math.min(...arr)
let largesttNo = Math.max(...arr)

console.log(SmallestNo)
console.log(largesttNo)

chandreshkumar
Автор

Sir g react redux per video banao jaldi, achhe se samjana 🙏🙏

meditationmusic
Автор

Simplest way;
const arr = [12, 3, 5, 89, 1];
let maxno=Math.max.apply(null, arr);
let minno =Math.min.apply(null, arr);

Growfacts
Автор

let arr = [10, 20, 30, 40, 50];
let largest = Math.max(...arr);
let smallest = Math.min(...arr);
console.log("Largest element: " + largest);
console.log("Smallest element: " + smallest);

piotrnawrot
Автор

just sort it out as nlogn time comp
and arr[0] is min
and arr[arr.length-1] is max

deepmane
Автор

Can we use arr.sort()

Then let small = arr[0]
??

merakshay
Автор

Sir, YouTube per DS with javascript per koi acha channel nhi hai, ab please start kare

rishitgahlaut
Автор

const smallLargeElem = (array) => {
let sort = array.sort((a, b) => a-b)
let smallest = sort[0]
let largest = sort[array.length-1]

return (`largest: ${largest} and smallest: ${smallest}`)
}

const res = smallLargeElem([12, 3, 5, 89, 1])
console.log(res)

chetangupta
Автор

also explain how to do the same thing in objects..
'

NotYour_Gurlyy
welcome to shbcf.ru