From bcec7623cd64c1052528069d74e1f5615be6ec17 Mon Sep 17 00:00:00 2001 From: Magdalena Grzesik Date: Mon, 17 Jun 2024 20:01:43 +0200 Subject: [PATCH 1/3] Add task 01 --- 01/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/01/app.js b/01/app.js index 96dc2f5..0bfa549 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,10 @@ const randomNumber = Math.round(Math.random() * 20); console.log(randomNumber); + +if (randomNumber > 5) { + for (let i = randomNumber; i <= 20; i++) { + console.log(i); + } +} else { + console.log("Wylosowana liczba jest za mała, aby użyć pętli"); +} From c957f9418d025a01fe33be1e6043bec0a423cc5f Mon Sep 17 00:00:00 2001 From: Magdalena Grzesik Date: Tue, 18 Jun 2024 21:35:29 +0200 Subject: [PATCH 2/3] Add task 02 --- 02/app.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..26bcab4 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,15 @@ const x = 5; -let result = 0; \ No newline at end of file +let result = 0; +let i = 1; + +// for (i; (i <= x); i++) { +// result = ((1 + i) / 2) * i; + +// console.log(result); +// } + +while (i <= x) { + result = ((1 + i) / 2) * i; + i = i + 1; + console.log(result); +} From 3d0b883cc54555709923ee5a00c21460c90cff7d Mon Sep 17 00:00:00 2001 From: Magdalena Grzesik Date: Tue, 18 Jun 2024 21:49:23 +0200 Subject: [PATCH 3/3] Add task 03 --- 03/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c26c886..3f8defd 100644 --- a/03/app.js +++ b/03/app.js @@ -1,3 +1,12 @@ const x = 10; let iteration = 0; -let randomNumber = -1; \ No newline at end of file +let randomNumber = -1; + +while (x !== randomNumber) { + randomNumber = Math.round(Math.random() * 20); + iteration = iteration + 1; +// console.log(iteration); +// console.log(randomNumber); +} + +console.log("Wylosowano za " + iteration + " razem");