# Returning a boolean (changing its value) - issue

Hi i am having an issue changing the three variables back to false. What am i missing? It seems like i’ve missed something elementary out regarding booleans and the altering of their values?

``````if (eye == true || mouth == true || nose == true ) {
eye = false && nose = false && mouth = false }
``````

thanks

``````function countSmileys(arr) {
let smileycounter = 0;
let eye = false;
let nose = false;
let mouth = false;

for (let i = 0; i < arr.length; i++) {
var subArray = arr[i];
for (let j = 0; j < subArray.length; j++) {
if (subArray[j] === ":" || subArray[j] === ";") {
eye = true;
}
if (subArray[j] === "-" || subArray[j] === "~") {
nose = true;
}
if (subArray[j] === ")" || subArray[j] === "D") {
mouth = true;
}
}
if (eye === true && mouth === true) {
smileycounter++;
}
if (eye == true || mouth == true || nose == true ) {
eye = false && nose = false && mouth = false }

}
return smileycounter;
}

countSmileys([":)", ":(", ":D", ":O", ":;"]);
``````

Take another look at what you have in the inside the if statement, I think I know what you are trying to accomplish… but what would `a=a && b=b` return? true or false ?

at the end of the nested loop sequence i want to reset eyes, nose, and mouth to false (to clarify)

I try to run it like this with the strict equality but it doesn’t change nose,eye and mouth to false. This is why i tried changing it to =.

a=a and b=b is true?

``````if (eye == true || mouth == true || nose == true ) {
eye === false && nose === false && mouth === false }
``````

… It’s one of those things when you see it, it’ll click… you are close…

`eye = false` is correct for what you want, this sets eye to `false`

`eye === false && nose === false` is either `True or False`

`eye = false && nose = false` is ALWAYS false because you changed eye to `false` and the code will stop (since it found `false`)

`||` & `&&` are operators, so This OR This … or … This AND this … resulting in True/False …

```````eye = false && nose = false`  is ALWAYS false because you changed eye to  `false`  and the code will stop (since it found  `false` )

`||`  &  `&&`  are operators, so This OR This … or … This AND this … resulting in True/False …
``````

oh so operators `||` & `&&` only look for the first value and then return true/false based on the first answer. didn’t know.

i removed the && and it finally worked Good work! … and yes in general `operators || & &&` are looking going to give a true/false, so they are good to use inside of the `if( )` , and it will stop once it gets a false. So if there were a million things to check, it could stop once it found the first false… instead of running through all 3 for a total of 3 millions times every time.

The only other minor thing I’d note that is that you can just use the variable name for “truthiness”

`if (eye == true || mouth == true || nose == true ) {`
is the same as:
`if (eye || mouth || nose ) { ...`

Happy Coding 1 Like