Skip to content
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

resolving task no.4 with ugly code #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Chester97
Copy link

No description provided.

Copy link

@bear-in-a-box bear-in-a-box left a comment

Choose a reason for hiding this comment

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

Good thinking overall. The real issue here is naming.

app.js Outdated
return convertToHours(getFullTimeOfSleep);
}
}
const getMiliseconds = (h,m) => {

Choose a reason for hiding this comment

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

Please provide default values, e.g. 0

app.js Outdated
const convertedClockStop = clockStop.split(":");
const msMotive = convertToMs(convertedMotive[0],convertedMotive[1]);
const msClockStop = convertToMs(convertedClockStop[0],convertedClockStop[1]);
const maxNum = Math.max(...[msMotive,msClockStop]);

Choose a reason for hiding this comment

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

Why create an array and use spread? Math.max(msMotive, msClockStop) would suffice.

app.js Outdated
@@ -0,0 +1,34 @@
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => {

Choose a reason for hiding this comment

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

Good idea with taking output formatter as a function parameter. I'd give it a more meaningful name, though. convertToHours would be named outputFormatter, for example.

const msClockStop = convertToMs(convertedClockStop[0],convertedClockStop[1]);
const maxNum = Math.max(...[msMotive,msClockStop]);
const minNum = Math.min(...[msClockStop,msMotive]);
if(maxNum && minNum > 0) {

Choose a reason for hiding this comment

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

What if this condition is evaluated as false? What would be returned then?

@@ -0,0 +1,34 @@
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => {
const convertedMotive = motiveTime.split(":");

Choose a reason for hiding this comment

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

Variable names don't say much. If I didn't see the values, I wouldn't know what is stored and assigned to them.

app.js Outdated
return ((h*60*60+m*60)*1000);
}

function timeConversion(millisec) {

Choose a reason for hiding this comment

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

There would be a better name, e.g. formatTimeToString.

app.js Outdated
@@ -0,0 +1,34 @@
const convertTime = (motiveTime, clockStop, convertToMs, convertToHours) => {

Choose a reason for hiding this comment

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

The function shouldn't have 4 params

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.

3 participants