Javascript algorithms - Use of boolean logic with if statements

function trueOrFalse() {
// Cambia solo el código debajo de esta línea
if (wasThatTrue){
return “Yes that was true”;
}else{
return “No, that was false”;
};

console.log(trueOrFalse(true));
console.log(trueOrFalse(false));

// Cambia solo el código encima de esta línea

}

SyntaxError: unknown: Unexpected character ‘“’.
use normal quotes ""

function trueOrFalse(wasThatTrue){}
return "Yes ,that was true"

add comma

Thanks for the response but its not working.

Regards.

function trueOrFalse(wasThatTrue) {
// Cambia solo el código debajo de esta línea
function trueOrFalse(wasThatTrue){
return “Yes, that was true”;
}
return “No, that was false”;
// Only change code above this line.
}

// Cambia solo el código encima de esta línea

change the quotes " "

Quotes seem to be fine.

This is what im missing:

“trueOrFalse(true)” should return the string “Yes, that was true”.

you have two functions

where is your if statment?

 “ ”

SyntaxError: unknown: Unexpected character ‘“’
use normal quotes

function trueOrFalse(wasThatTrue) {

// Cambia solo el código debajo de esta línea

if wasThatTrue(true){

return "Yes, that was true";

}

return "No, that was false";

}

I’m not using any different quotes, you are seeing them different for whatever reason.

Thanks for the help but i dont understand why theres one function that should be enough “trueOrFalse” and then why do i need another function “wasThatTrue” or argument i dont understand how computer understand that as a parameter if its not a reserved word.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

A function is not a parameter. A parameter is an input for a function.

This isn’t like the example of how you use an if statement that you were given.

ok wait, wait, wait.

Ok backticks for the code. Is it the same if i use any other signs comas or apostrophs? Or is it necesary only back ticks?

Preformated text tool, where is that i dont see anything on my browser nor in settings.

I know a function is not a parameter but if im right i’ve seen do a function inside of a function would could be confusing as paramenters seem to be inside of a function for the most part. And why isnt there a “true” as a parameter but a “wasThatTrue” parameter i dont understand.

Only backticks. No other characters.

Calling functions inside of functions is completely different than using the function parameters inside of a function.

true is a value, like 6. You cannot name a parameter after a literal value.

This is what you gave us:

function test(myCondition) {

  if (myCondition) {

    return "It was true";

  }

  return "It was false";

}

test(true);
test(false);

and this is what i did

function trueOrFalse(wasThatTrue) {

  // Cambia solo el código debajo de esta línea

if wasThatTrue(true){

return "Yes, that was true";

}

return "No, that was false";

}

First comes the function with the paramenters then curly braces to enter the inside of the function. Parameters shouldnt be true or false? why is there this wasThatTrue expresion if its not declared or mentioned before idk where it comes from or what to do with it.

Look at this

This looks very different

ok yes idk why it made sense in my mind

Learning this stuff is hard. It’s a soup of letters at first

1 Like

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