From 22ca4f4958a19a93137730bcba838c4706991ade Mon Sep 17 00:00:00 2001 From: Fredrik Uddenfeldt Date: Sat, 20 May 2023 21:58:15 +0200 Subject: [PATCH] first iteration with faulty but promising loop --- 05_sumAll/sumAll.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/05_sumAll/sumAll.js b/05_sumAll/sumAll.js index 00880c7..92dcc78 100644 --- a/05_sumAll/sumAll.js +++ b/05_sumAll/sumAll.js @@ -1,6 +1,28 @@ -const sumAll = function() { +// First iteration pseudocode: +// Take two arguments. +// Loop between them. +// Store the value +// If negative or or non-number parameters: return ERROR +// +// +// First iteration with a faulty but promosing loop: + +const sumAll = function(x, y) { + let theSum; + for (let i = x; i <=y; i++) { + x += i + } + + console.log(theSum) + }; + +sumAll(1,10) + +// Need to add conditions for ERROR-message + + // Do not edit below this line module.exports = sumAll;