NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 3

Get highest number in the array || javascript

You can find the highest number in an array in JavaScript

using the Math.max and DSA algo

Here's is the Code !!

// Neel.B
const givenArray = [2,3,12,44,98,55] 
let firstElement = givenArray[0] // assume it's highest
let arrayLength  = givenArray.length
for(let count = 1; count < arrayLength; count++) {
	if(givenArray[count] > firstElement) { 
		firstElement = givenArray[count]
	}
}
console.log(firstElement) //output : 98
//OR
console.log(Math.max(...givenArray))

Chapter 2

Copy by reference example in object || javascript

Previous chapter

Chapter 4

Clouser function in javascript || encapsulate the outer function variables.

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex