Control Flow 13/14


#1

Hello there I am having trouble with the excersise, can't figure why isn't returning false when both params are false.

May be you can help out!

Thank you.

// Declare your variables here!
var tired = false;
var bored = true;

var nap = function(val1, val2) {
// Add your if/else statement here!
if(val1 === true || val2 === true){
return true;
}else if(val1 === false && val2 === true){
return false;
}else if(val1 === false && val2 === true){
return true;
}else if(val1 === false && val2 === false){
return false;
}
};


#2

As I recall, this exercise does not ask us to write any parameters in the function. We are to use the globals, tired and bored within the function.

var nap = function () {

};

#3

My code looked like this:

var tired = true;
var bored = false;

var nap = function() {
if ( tired || bored) {
return true;
} else {
return false;
}
};
nap();

This should return true b/c val2 is true. also, last thing, nap(); at the end of the script.

I'm not 100% on this, but I used your code and played with it, those are the changes I made and they worked.


#4
false && true  =>  false

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.