From 253525fdfab0c34d915245f6a05d97f042e5d3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ko=C5=82odziej?= Date: Sat, 30 Jul 2022 19:16:06 +0200 Subject: [PATCH 1/4] finish task petla --- 01/app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/01/app.js b/01/app.js index 96dc2f5..01c8f40 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,12 @@ const randomNumber = Math.round(Math.random() * 20); console.log(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') +} \ No newline at end of file From 2bc7c613d86ee6a60dc04ae3161703c1ae1f51bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ko=C5=82odziej?= Date: Mon, 1 Aug 2022 00:48:39 +0200 Subject: [PATCH 2/4] finish petla task2 --- 02/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..144e797 100644 --- a/02/app.js +++ b/02/app.js @@ -1,2 +1,8 @@ const x = 5; -let result = 0; \ No newline at end of file +let result = 0; + +for(let i=0; i<=x; i++) { + result = result + i; +} + +console.log(result); \ No newline at end of file From e1e21d57d7452408f8cde61d35d3b2859d663a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ko=C5=82odziej?= Date: Mon, 1 Aug 2022 01:06:39 +0200 Subject: [PATCH 3/4] finish petla task22 --- 02/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 144e797..580f431 100644 --- a/02/app.js +++ b/02/app.js @@ -1,8 +1,16 @@ const x = 5; let result = 0; -for(let i=0; i<=x; i++) { +// for(let i=0; i<=x; i++) { +// result = result + i; +// } + +// console.log(result); + +let i = 0; +while(i<=x) { result = result + i; + i++; } console.log(result); \ No newline at end of file From a1657b9aed59831d16a74514d0b1fae362695570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Ko=C5=82odziej?= Date: Mon, 1 Aug 2022 01:35:38 +0200 Subject: [PATCH 4/4] finish petla task3 --- 03/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c26c886..cdfacad 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 +let randomNumber = -1; + +while(randomNumber !== x) { + randomNumber = Math.round(Math.random() * 20); + iteration++; +} + +console.log(iteration); \ No newline at end of file