Skip to content

Feature/quiz timer#19

Merged
MariaBanaszkiewicz merged 7 commits intodevelopfrom
feature/quiz-timer
Dec 8, 2021
Merged

Feature/quiz timer#19
MariaBanaszkiewicz merged 7 commits intodevelopfrom
feature/quiz-timer

Conversation

@MariaBanaszkiewicz
Copy link
Collaborator

Quiz timer, that counts time up in real-time.

@MariaBanaszkiewicz MariaBanaszkiewicz linked an issue Dec 5, 2021 that may be closed by this pull request
2 tasks
@Nefariusek Nefariusek self-requested a review December 6, 2021 17:06
src/main.js Outdated
`;
document.querySelector('#app').appendChild(createTimer());
startTimer();
//setTimeout(stopTimer, 1000 * 35);
Copy link
Owner

Choose a reason for hiding this comment

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

Remove the commented-out code

@@ -0,0 +1,57 @@
var timer;
Copy link
Owner

Choose a reason for hiding this comment

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

avoid using vars

Comment on lines +4 to +20
const clock = document.createElement('div');
clock.setAttribute('id', 'clock');

const image = document.createElement('img');
image.setAttribute('id', 'clk_img');
image.src = '/timer.png';

const minutes = document.createElement('span');
minutes.setAttribute('id', 'min');
minutes.innerText = '00';

const colon = document.createElement('span');
colon.innerText = ':';

const seconds = document.createElement('span');
seconds.setAttribute('id', 'sec');
seconds.innerText = '00';
Copy link
Owner

Choose a reason for hiding this comment

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

To improve readability, replace abbreviations in ids with full names eg. min-> minutes or even timer-minutes

Comment on lines +7 to +10
const image = document.createElement('img');
image.setAttribute('id', 'clk_img');
image.src = '/timer.png';

Copy link
Owner

Choose a reason for hiding this comment

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

Instead of clk_img, we can use selector #clock img

Comment on lines +31 to +32
let minutes = 0,
seconds = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

this approach is harder to extend/modify

use:

let minutes = 0;
let seconds = 0;

Comment on lines +36 to +37
min.innerText = '00';
sec.innerText = '00';
Copy link
Owner

Choose a reason for hiding this comment

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

It is duplicated in createTimer function;

Keep it just here

Comment on lines +47 to +49
min.innerText = minutes < 10 ? '0' + minutes : minutes;
}
sec.innerText = seconds < 10 ? '0' + seconds : seconds;
Copy link
Owner

Choose a reason for hiding this comment

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

Use a separate function to check this condition. Pass minutes/seconds, return what should be assigned to innerText

Copy link
Owner

@Nefariusek Nefariusek left a comment

Choose a reason for hiding this comment

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

LGTM

@Nefariusek
Copy link
Owner

@MariaBanaszkiewicz please resolve conflits and merge this pull request

@MariaBanaszkiewicz MariaBanaszkiewicz merged commit 19c7f6f into develop Dec 8, 2021
@MariaBanaszkiewicz MariaBanaszkiewicz deleted the feature/quiz-timer branch December 8, 2021 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI/Logic] Quiz timer

2 participants