From b9897936980bdadcaedce80b558feb56c99a6748 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Sun, 24 Nov 2024 15:50:30 +0100 Subject: [PATCH 1/3] resolved exercise 1 --- 01/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/01/app.js b/01/app.js index 96dc2f5..7e38846 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,11 @@ const randomNumber = Math.round(Math.random() * 20); -console.log(randomNumber); +console.log(`Wylosowana liczba to: ${randomNumber}`); + +if (randomNumber > 5){ + for (let i=5; i <= randomNumber; i++){ + console.log(i); + } +} +else { + console.log(`Wylosowana liczba jest zbyt mała, aby użyć pętli`); +} From e6975941947692ddf733f3c844fbaa8231a3aff7 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Sun, 24 Nov 2024 16:17:28 +0100 Subject: [PATCH 2/3] resolved ex 2 --- 02/app.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..90bdd64 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,16 @@ const x = 5; -let result = 0; \ No newline at end of file +let result = 0; + +for (let i = 1; i <= x; i++) { + result += i; +} +console.log(`Suma dla podanych liczb to ${result}`); + +let j = 1; +let sum = 0; + +while (j <= x){ + sum += j; + j++; +} +console.log(`Suma dla podanych liczb za pomoca while to ${sum}`); \ No newline at end of file From df8a0758bc6733576b5e204f8977ccf88f0e46a8 Mon Sep 17 00:00:00 2001 From: marrcelp Date: Sun, 24 Nov 2024 16:43:17 +0100 Subject: [PATCH 3/3] resolved exercise 3 --- 03/app.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c26c886..097d1dc 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 = Math.round(Math.random() * 20); + +while (randomNumber !== x){ + randomNumber = Math.round(Math.random() * 20); + console.log(`Wylosowano ${randomNumber}`); + iteration++; + +} + +console.log(`Wylosowano te sama liczbe za ${iteration} razem`) \ No newline at end of file