Image for post
Image for post
  1. Find the largest element in an array
var arr = [10, 20, 30, 40, 50];var max = arr[0];for(var i=0; i < arr.length; i++) {  var a = arr[i];  if(a > max){    max = a;  }}console.log(“Largest in the array: “, max);

2. Sum of all the elements in an array

var arr = [10, 20, 30, 40, 50];var sum = 0;for(var i=0; i < arr.length; i++) {  var a = arr[i];  sum += a;}console.log(“Sum of the elements in the array: “, sum);

3. Remove duplicate items from an array

var arr = [10, 20, 30, 20, 40, 30…

About

MD. AMINUL ISLAM

B.Sc. in Computer Science and Engineering. University of Barishal, Barishal.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store