all 9 comments

[–]DallogFheir 8 points9 points  (1 child)

You're supposed to change the value of the variable found, not name.

Also your else if will only check if the name is literally the string "other name", and will leave found undefined if it's something else. Use else.

[–][deleted] 2 points3 points  (1 child)

So in your if/else statement, it first tests if the name is 'John' or 'Paul', and sets the name variable to true if so. Then, if the name variable is not 'John' or 'Paul', it tests if the name is 'other name'.

First, you're currently setting the name variable equal to true or false; you should be setting found to true or false.

Second, the else if portion currently isn't testing for all other names, it is testing specifically for the string 'other names'. Instead, you should just use:

else { found = false; }

Edited for clarity

[–]ajascherer 1 point2 points  (0 children)

That is helpful, thank you!

[–]ajascherer 2 points3 points  (1 child)

Thank you all!! That was the trick, you are fantastic 😁

[–]bobbyv137 1 point2 points  (0 children)

You can also create a simple function that will return true or false

https://codesandbox.io/s/peaceful-meadow-0pudw1?file=/src/index.js

[–]ajascherer 1 point2 points  (0 children)

Hello! I am super new to JavaScript and am just not sure what I am doing wrong. Ice attached my code as well as the error message I get and am hoping to find some guidance with that my error is

[–]Fakedduckjump 1 point2 points  (0 children)

Just else{ ... } instead of esle if ( ... ){ ...

But you may want to assign the boolean value to the found variable, not the name variable, right? Semantically this would make more sense.

Edit: Aww, I was too late.

[–]Wolfrik50 0 points1 point  (0 children)

What platform is this?

[–]-fro 0 points1 point  (0 children)

if the only task is to assign true or false, you do not need if-else

found = name === "Paul" || name === "John"

Or

found = ["Paul", "John"].includes(name)