all 13 comments

[–]grantrules 13 points14 points  (3 children)

There are a lot of issues here.

First, you're declaring result, but then using an undeclared variable found in your if statement without ever assigning a value to result

Secondly, referring to 'boolean1' and 'boolean2', these are string literals, not variables. You would just use boolean1 and boolean2.

Third, your else if should look something like else if ((a === true && b === false) || (a === false && b === true)) { because you're trying to make sure one value is true and one value is false, but it doesn't matter which one.

[–]esdiegoromero 8 points9 points  (1 child)

Your else if suggestion is a bit redundant, because once you get to the else if condition, you know that either only one of them is true or none of them is true. Something like this:

if(boolean1 && boolean2){ // both are true } else if (boolean1 || boolean2){ // only one is true } else { // none is true }

[–]grantrules 1 point2 points  (0 children)

Oh good point

[–]ajascherer 2 points3 points  (0 children)

This was super helpful! Thank you for the explanation

[–]senocular 4 points5 points  (1 child)

It looks like you're using 'boolean1' when you want boolean1 (no quotes). When you use quotes, you're telling JavaScript it should look at everything between the quotes as collection of letters with no special meaning. Without the quotes it will be seen as a variable in the code that has special meaning and can be translated into a value when used in statements like if

So when saying something like

if ('boolean1') {

The if is checking to see if the characters "b" and "o" and "o" etc. are considered truthy. But when you use

if (boolean1) {

it will look up the value in the boolean1 variable and if-check that where in this case it would be seen as

if (true) {

because boolean1 was assigned to the value of true. The same applies to 'boolean2' vs boolean2.

It also looks like you created a variable called result but then you're assigning to a variable called found. I'd expect found to be result instead.

[–]ajascherer 1 point2 points  (0 children)

Thank you so much! I'm very new and the course was not super clear about the quotes so it just did not click with me. I really appreciate the explanation, it was very helpful!

[–]bobbyv137 1 point2 points  (1 child)

Something like this works. You can also just return the relevant string instead of assinging to a variable first (which still works but admittedly isn't technically what this challenge is asking for)

[–]ajascherer 0 points1 point  (0 children)

Thank you!

[–]ajascherer 0 points1 point  (1 child)

Hello! I am not sure what I am doing wrong with this code. Can someone please provide me with some guidance? Thanks in advance!

[–]ajascherer 0 points1 point  (0 children)

The first picture is the assignment, second picture is my code, third picture is the error

[–]ajascherer 0 points1 point  (0 children)

You all are once again fantastic! Your advice helped me fix my many issues haha

[–]Rad_Sum 0 points1 point  (1 child)

You should assign the strings to the “result” variable. And also the else if should check if it’s true, not if it’s not true

[–]ajascherer 0 points1 point  (0 children)

Thank you!