JavaScript Rest Operator

Free Web development courses with real-time projects Start Now!!

Program 1

<html>
    <head>
        <script>
            function marksheet(rno,name,...args)
            {
                      console.log(rno + "      "+ name)
                      let i,sum=0,p,n
                      n=args.length
                      for(i=0;i<args.length;i++)
                      {
                            sum=sum+args[i]
                      }
                      console.log("Total Marks : "+sum)
                      p=sum/n
                      console.log("Percentages : "+p)

            }

            marksheet(101,"vishal Sharma",78,88,99,75)
            console.log("------------------------------------")
            marksheet(102,"Anil Mishra",76,78,89,85,89)
            console.log("------------------------------------")
            marksheet(103,"Rupali Shrama",76,74,56,88,67)
            console.log("------------------------------------")

            marksheet(104,"Vivek Gupta",99,89,90,98,89,99)
            console.log("------------------------------------")






            //  function addition(...args)   //rest operator
            //  {
            //    //   console.log(args.length)
            //       let i,sum=0
            //        for(i=0;i<args.length;i++) 
            //        {
            //          console.log(args[i])
            //          sum=sum+args[i]
            //        }  
            //       return sum 
            //  }
            //  let s
            // s=addition(40,20)
            //   console.log("Addition is " +s)
            //  console.log("-----------------------")
            //  s=addition(40,20,30)
            //  console.log("Addition is " +s)
            //  console.log("-----------------------")
            //  s=addition(40,20,40,60)
            //  console.log("Addition is " +s)
            //  console.log("-----------------------")
            //  s=addition(40,20,40,60,12)
            //  console.log("Addition is " +s)
            //  console.log("-----------------------")
        </script>
    </head>
 
    <body>
      <center>
       <h1>Check Rest Operator  in Java Script</h1>
     </center>
    </body>
</html>

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

Leave a Reply

Your email address will not be published. Required fields are marked *