From 872aaf86129fabdc36126526a94e02aff07886e3 Mon Sep 17 00:00:00 2001 From: Rafal Date: Tue, 23 Jan 2024 20:25:36 +0000 Subject: [PATCH 1/3] Random number --- 01/app.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/01/app.js b/01/app.js index 96dc2f5..a89dc4c 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,11 @@ -const randomNumber = Math.round(Math.random() * 20); -console.log(randomNumber); +for (let j = 0; j < 5; j++) { + const randomNumber = Math.round(Math.random() * 20) + + 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 3cb772d88f80f32fc4970ef51bc0521f98b0b3a3 Mon Sep 17 00:00:00 2001 From: Rafal Date: Tue, 23 Jan 2024 20:29:50 +0000 Subject: [PATCH 2/3] Drawing numbers --- 02/app.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..181258f 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,18 @@ const x = 5; -let result = 0; \ No newline at end of file +let result = 0; + +for (let i = 1; i <= x; i++) { + //result += i; + result = result + i +} +console.log(result) + +const x1 = 5 +let result1 = 0 +let j = 1 + +while (j <= x1) { + result1 += j + j++ +} +console.log(result1) \ No newline at end of file From 55d8563d7f77cb07dc7d5dc67b49895a268bd44c Mon Sep 17 00:00:00 2001 From: Rafal Date: Tue, 23 Jan 2024 20:33:10 +0000 Subject: [PATCH 3/3] Iteration numbers --- 03/app.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/03/app.js b/03/app.js index c26c886..565fa2b 100644 --- a/03/app.js +++ b/03/app.js @@ -1,3 +1,10 @@ -const x = 10; -let iteration = 0; -let randomNumber = -1; \ No newline at end of file +const x = 5 +let iteration = 0 +let randomNumber + +while (randomNumber !== x) { + randomNumber = Math.floor(Math.random() * 10) + 1 + iteration++ +} + +console.log("Liczba iteracji: " + iteration)