Where am I going wrong


#1


https://www.codecademy.com/courses/spencer-sandbox/0/1?curriculum_id=506324b3a7dffd00020bf661


I a getting this error
"You have gotten the wrong answer"


var abc = function() { 
    if(3*90 === 270) {
      return true; }
  };
abc();

var def = function() {
    if(!(false && (!false))) {
        return true; }
};
def();

var ghi = function() {
    if("bex".toUpperCase() === "BEX") {
        return true; }
};
ghi();

var answer = function() {
    if(abc() || def() || ghi() === true) {
        return true;
    }
};
answer();


#2

@manishbjain,
In the end,
the exercise expects an answer variable with an associated Boolean Value of true or false

The shortest way, keeping most of your code
would be to execute your anonymous function using a ()
like

function() {
    if(abc() || def() || ghi() === true) {
        return true;
    }
}()

and if you encapsulate that in a pair of parenthesis
the interpreter see's the construct as a so-called auto-executer
thus

var abc = function() { 
    if(3*90 === 270) {
      return true; }
  };
abc();

var def = function() {
    if(!(false && (!false))) {
        return true; }
};
def();

var ghi = function() {
    if("bex".toUpperCase() === "BEX") {
        return true; }
};
ghi();

var answer = (function() {
    if(abc() || def() || ghi() === true) {
        return true;
    }
}());

console.log(answer);

#3

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