Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <button>Test</button>
- <script id="jsbin-javascript">
- //Rest operator
- //The ...(rest operator) takes a list of numbers and packs them togheter in an array.
- function sumUp(...toAdd){
- let result = 0;
- for(let i = 0; i < toAdd.length; i++){
- result += toAdd[i];
- }
- return result;
- }
- console.log(sumUp(100,20,30));
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">//Rest operator
- //The ...(rest operator) takes a list of numbers and packs them togheter in an array.
- function sumUp(...toAdd){
- let result = 0;
- for(let i = 0; i < toAdd.length; i++){
- result += toAdd[i];
- }
- return result;
- }
- console.log(sumUp(100,20,30));</script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement