Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

What am I doing wrong?

Name: Anonymous 2016-12-18 12:34

var sleepCheck= function(numHours)
{
if(sleepCheck => 8)
{
return "You're getting plenty of sleep! Maybe even too much!";
};
else {
return "Get some more shut eye!";
};

sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

Name: Anonymous 2016-12-18 13:09

You're
DID YOU JUST ASSUME MY PRONOUNS?
#diecisscum #genderprivelege #smashthepatriarchy

Name: Anonymous 2016-12-18 14:01

You are posting code without the corresponding tag, [ code ].

Name: Anonymous 2016-12-18 14:04

You're returning a string in a function that only has two possibilities. You also appear to be using javascript. I've rewritten it in a sensible language. Note how the function name gives enough information as to what the function will return. Then they can print whatever string they want.
int enough_sleep(double hours) {
return(hours >= 8 ? 1 : 0);
}

Name: Anonymous 2016-12-18 17:35

>>1
You're using JavaScript.
You're using a needlessly verbose syntax.
You're not indenting your code properly.
You're using superfluous semicolons and line breaks.
You're writing code that is dependent on ``magic numbers" and not conductive to internationalization.

In short, you are most certainly not an EXPERT PROGRAMMER

Name: Anonymous 2016-12-18 17:51

That's not a proper goesto operator.

Name: Anonymous 2016-12-31 23:25

var sleepMoreCallback = function() { return "Get some more shut eye!" }
var sleepLessCallback = function() { return "You're getting plenty of sleep! Maybe even too much!" }

var sleepCheckFunction = function(hoursInt, maxHoursInt, lessCallback, moreCallback) {
if(hoursInt >= maxHoursInt) {
moreCallback()
} else {
lessCallback()
}
}

sleepCheckFunction(10)
sleepCheckFunction(5)
sleepCheckFunction(8)

Name: Anonymous 2017-01-01 3:43

>>7
You should return the value returned from the callback in sleepCheckFunction().

Don't change these.
Name: Email:
Entire Thread Thread List