Blogger

Delete comment from: Java67

Anonymous said...


var a = [100, 500, 1000, 5000, 350000, 100000, 200000, 15, 20, 30, 25, 2];
var b = [];
function largestNumber(a){
for(let i=0; i<= a.length-2 ;i++){
// console.log(a[i])

if(i==0){
b.push(a[i])
}

if (i > 0){
if(b[0] <= a[i+1]){

b.pop()
b.push(a[i+1])
}
}
else if(b[0] <= a[i+1]){
b.pop()
b.push(a[i+1])
}
console.log(b +" is bigger number than " + a[i+1])
}
}
largestNumber(a)
console.log(b)

Dec 10, 2019, 5:25:34 PM


Posted to How to find largest and smallest number from integer array - Java Solution

Google apps
Main menu