eloquent javascript exercise 4:2

In this example below you will see how to do a eloquent javascript exercise 4:2 with some HTML / CSS and Javascript

eloquent javascript... the solution of sum of range exercise on chapter 4...

Thumbnail
This awesome code was written by 241188, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 241188 ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>eloquent javascript exercise 4:2</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/241188/eloquent-javascript-exercise-42-GjWbyY */
var arr=[] 
  function range(start,end,step){ 
    if(step==null) step=1;
   for(var x=start; (x+step)<(end+step+1) ;x=x+step) 
  arr.push(x)  
      return arr
  }
 
function sum() {
  var result=0
  for(var y=0; y<arr.length;y++)
    result+=arr[y]
    return result
}

Comments