Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion 01/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
const randomNumber = Math.round(Math.random() * 20);
console.log(randomNumber);

if (randomNumber > 5) {
for (i = 5; i <= randomNumber; i++) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uwaga na deklaracje zmiennej! - zabrakło let przy i - w takim wypadku i jest zmienną globalną, co nie jest dobrą praktyką.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devmentor-pl faktycznie, nie wiem skąd mi się to wzięło - będę pamiętać :)

console.log(i);
}
} else {
console.log("Wylosowana liczba jest zbyt mała, aby użyć pętli!");
}
15 changes: 14 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
const x = 5;
let result = 0;

let resultFor = 0;
for (let i = 1; i <= x; i++) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tutaj jest już ok :)

resultFor = resultFor + i;
console.log(resultFor);
}

let resultWhile = 0;
let j = 1;
while (j <= x) {
resultWhile = resultWhile + j;
j++;
console.log(resultWhile);
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

11 changes: 9 additions & 2 deletions 03/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const x = 10;
const x = 5;
let randomNumber;
let iteration = 0;
let randomNumber = -1;

while (randomNumber !== x) {
randomNumber = Math.round(Math.random() * 20);
console.log(randomNumber);
iteration++;
}
console.log(`Potrzebowałaś ${iteration} prób/y.`);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍