diff --git a/01/app.js b/01/app.js index 96dc2f5..486b195 100644 --- a/01/app.js +++ b/01/app.js @@ -1,2 +1,12 @@ -const randomNumber = Math.round(Math.random() * 20); +const randomNumber = Math.round(Math.random() * 10); 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') +} + + diff --git a/02/app.js b/02/app.js index 8a41914..e47e06a 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 (let i = 1; i <= x; i++) { + result = result + i; +} +console.log("Suma liczb od 1 do", x, "wynosi:", result); + +// while (i <= x) { +// result = result + i; +// i ++; +// } + +// console.log("Suma liczb od 1 do", x, "wynosi:", result); \ No newline at end of file diff --git a/03/app.js b/03/app.js index c26c886..e0d3fb0 100644 --- a/03/app.js +++ b/03/app.js @@ -1,3 +1,9 @@ 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('Tyle losowań =', iteration, 'potrzeba do wylosowania', x) \ No newline at end of file