Define a function that a number n as parameter and returns the sum of the
numbers from 1 to n Javascript Program

let n=20;
function findSum(n)
{
   let sum = 0;
   for (let x = 1; x <= n; x++)
     sum = sum + x;
   return sum;
}
console.log(findSum(n));
 

Check Also

How to debugg our flutter application

Debugging a Flutter application involves a variety of techniques and tools to identify and fix …

Leave a Reply

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