-
Notifications
You must be signed in to change notification settings - Fork 172
functions exercises #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
functions exercises #130
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function showTime() { | ||
| const time = new Date().toLocaleTimeString(); | ||
| console.log(time); | ||
| } | ||
|
|
||
| showTime(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| function sayHello(name) { | ||
| name = "devmentor.pl!"; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tutaj jest błąd sam parametr przyjmuje jakaś wartość - nie należy go nadpisywać. Ta linia jest niepotrzebna. |
||
| console.log(`czesc ${name}`); | ||
| } | ||
| sayHello(name); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dopiero tutaj definiujemy wartość dla parametru - powinno być |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| function () { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Czyli zaczynamy od czegoś takiego const |
||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| let counter = 1; | ||
| let counterTwo = 1; | ||
| let idInterval; | ||
| let stopTime; | ||
|
|
||
| function runTime() { | ||
| const time = new Date().toLocaleTimeString(); | ||
| console.log(time); | ||
|
|
||
| const showTimeCounter = function () { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| counterTwo++; | ||
| if (counterTwo > 5) { | ||
| clearInterval(stopTime); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trzeba jeszcze tylko podmienić odpowiednią nazwę zmiennej: |
||
| } | ||
| }; | ||
| } | ||
| const showCounter = function () { | ||
| console.log(counter); | ||
| counter++; | ||
|
|
||
| if (counter > 5) { | ||
| clearInterval(idInterval); | ||
| } | ||
| }; | ||
|
|
||
| idInterval = setInterval(showCounter, 2000); | ||
| stopTime = setInterval(showCounter, 2000); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIe wiem dlaczego tutaj uruchamiasz 2 razy tą samą funkcję. Zostawmy pierwsze uruchomienie i podmieńmy nazwę funkcji tj. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| <title>JavaScript: Podstawy, funkcje #04 - devmentor.pl</title> | ||
| </head> | ||
| <body> | ||
| <script src="./app.js"></script> | ||
|
|
||
| <script src="../04/scrypt.js"></script> | ||
| <script src="./ap.js"></script> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dlaczego tutaj coś zmieniałeś? Powinno być |
||
| </body> | ||
| </html> | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍