You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exer_8_function3.js 274B

123456789101112131415161718192021
  1. /* declaratie variablen */
  2. 'use strict'
  3. /* function */
  4. function sumToN(n) {
  5. let sum = 0;
  6. let count = 0;
  7. while (true) {
  8. if (count > n) {
  9. return sum;
  10. }
  11. sum += count;
  12. count++;
  13. }
  14. }
  15. /* output */
  16. let result = sumToN(10)
  17. console.log(result);