JSFiddle - React, Tailwind, and code Playground

by sanat gupta

JavaScript

function sum(){
	const argu = [...arguments];
  const lastIndex = argu.length - 1;
  var total = 0;
  
  argu.forEach((item,index)=>{
    if(index === lastIndex){
    	total = total * item
    }else{
    	total = total + item
    }
  })
  return total;
}

console.log(sum(1,2,5,54,54,54,54,10))