用js进行加法计算

html加js代码

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 
 4 <head>
 5     <meta charset="UTF-8">
 6     <meta http-equiv="X-UA-Compatible" content="IE=edge">
 7     <meta name="viewport" content="width=device-width, initial-scale=1.0">
 8     <title>Document</title>
 9 </head>
10 
11 <body>
12     <script>
26         function sums(...rest){
27             let nums=0
28             for(let a=0; a<rest.length; a++){
29                 nums=rest[a]
30             }
31             console.log(nums)
32         }
33         sums(12,15,14)
34     </script>
35 </body>
36 
37 </html>

 

posted @ 2023-03-15 20:14  倾心一刻  阅读(59)  评论(0)    收藏  举报