function min(a,length){
  let min = a[0]
  if(length == 1){
    
    if(a[1] < min){min = a[1]}
  }
  else{
  
    
    for(let i = 0 ; i < length ; i++){
      if(a[i] < min){min = a[i]}
}}
  return min;
}


function max(a,length){
  let max = a[0]
  if(length == 1){
    
    if(max<a[1]){max = a[1]}
  }
  else{
  
    
    for(let i = 0 ; i < length ; i++){
      if(max < a[i]){max = a[i]}
}}
  return max;
}

let a = [3,6,2];
len = a.length

console.log('The min element in the array is ',min(a,len))

console.log('The max element in the array is', max(a,len)) 
by