From 6f5b07b808f32c2341185fd006167d9fcbf2b56d Mon Sep 17 00:00:00 2001 From: Agata Witczak Date: Fri, 31 Mar 2023 21:47:15 +0200 Subject: [PATCH 1/4] finished --- 01/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/01/app.js b/01/app.js index 96dc2f5..12aab16 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,9 @@ const randomNumber = Math.round(Math.random() * 20); console.log(randomNumber); + +if(randomNumber > 5) { + for(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 1b90d7ca1c7bd72e78068fd69a973dfd92729d76 Mon Sep 17 00:00:00 2001 From: Agata Witczak Date: Fri, 31 Mar 2023 22:21:18 +0200 Subject: [PATCH 2/4] 'for' finished --- 02/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 8a41914..5fcf8bf 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=1; i<=x; i++) { + result = result + i; + console.log('i=',i,'result=',result) +} +console.log(result) \ No newline at end of file From a9233a60d710bea6e4564e8189ea70c236a5ed17 Mon Sep 17 00:00:00 2001 From: Agata Witczak Date: Fri, 31 Mar 2023 22:51:56 +0200 Subject: [PATCH 3/4] 'while' finished --- 02/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/02/app.js b/02/app.js index 5fcf8bf..1b983d7 100644 --- a/02/app.js +++ b/02/app.js @@ -1,8 +1,16 @@ const x = 5; let result = 0; -for(let i=1; i<=x; i++) { +// for(let i=1; i<=x; i++) { +// result = result + i; +// console.log('i=',i,'result=',result) +// } +// console.log(result) + +let i=1 +while(i<=x) { result = result + i; + i++ console.log('i=',i,'result=',result) } console.log(result) \ No newline at end of file From eb55c29f1802ebad22df12cf1888cbc6f88be529 Mon Sep 17 00:00:00 2001 From: Agata Witczak Date: Fri, 31 Mar 2023 23:57:10 +0200 Subject: [PATCH 4/4] finished --- 03/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/03/app.js b/03/app.js index c26c886..0f8a5aa 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(randomNumber, iteration) +} +console.log(x,'została wylosowana za', iteration, 'razem') \ No newline at end of file