1/*To return a value from functions that we create, we can use a return
2statement. A return statement has the form:*/
3
4return someVal;
5
6//where someVal is any value.//
7
8
9/*This function has a single parameter, n, which is expected to be a
10positive integer. It returns the sum 1+2+...+n.*/
11
12function sumToN(n) {
13 let sum = 0;
14 for (let i = 0; i <= n; i++) {
15 sum += i;
16 }
17 return sum;
18}
19
20console.log(sumToN(3));
21Console Output
22
236