Bhaj's Word Checker explainer

What Is wrong un this puzzle?

1 Like

On the second if statement it says if (space[i !==’-’&& space[i !== word[i]]]) but it should be
if (space[i] !==’-’&& space[i]!== word[i])
you’ll need to change that on the second if statement too
This should help.


Dont help,not run! I dont know why isnt work

Hey there, I see the issue. It looks like in both if statements, the !== and '_' are inside the square brackets [] of space[i], like this:

if (space[i !== '_'])

Try changing it to this:

if (space[i] !== '_')

Same issue with the 2nd if statement, you have this:

if (space[i !== '_' && space[i !== word[i]]])

Try changing it to this:

if (space[i] !== '_' && space[i] !== word[i])

Hope this helps! Let me know if you have any questions.

I correct this but still dont run, i dont know what to do next!

Not sure what I’m doing wrong

could you past a screenshot of your code?

i think after the first return false there should be another bracket( } )
then after the second return false there will be only 3 brackets instead of 4, and you’ll want to have the return true between the second and third brackets…

Please help with this one. I am stuck on
Bahaji’s word checker.

could you post a screenshot of the code?

Hi, please check for me, I’ve ran this a few times and still keeps telling me to add return true in last line. Checked the example and also no matter how many times I rewrite the script cannot get the first return false in the if {}. Thanks a mill

update: managed to find where I was going wrong. the circled } is what was in the incorret place.

Can someone please help, I don’t understand what I’m doing wrong

You have an underscore ‘_’ and it must be a dash ‘-’

That should solve it! good luck!

1 Like

Continuing the discussion from Bhaj's Word Checker explainer:

Hi there, I checked my solution many times, but still have two different responses for my code. What is wrong there? Can’t find a mistake.

Hmm, your code looks alright to me, although I may have missed something.

I suspect this may be related to a bug where hidden parentheses might be added to code in certain situations.

The app may show something like this:

if (space[i] !== '-' && space[i] !== word[i])

when behind the scenes the code actually looks like this:

if (space[i] !== ('-' && space[i] !== (word[i])))

Try deleting the if statement test and rewriting it. That might do the trick. If it’s still an issue, try submitting a bug report by tapping the menu button in the top-right corner of the screen and selecting “Send Feedback”.

Hope to get you unblocked soon!

I am not able to find the key " = " in grasshopper keyboard

Hey there, it will appear as soon as you declare a variable with let.

Delete i from the parameters of the function, so that the only 2 parameters are space and word.

Then, inside the setup of the classic for loop, use the let key to declare i, like this:

for (let i = 0; i < word.length; i++)

That will do the trick.

Hope this helps!

Hi Ben,

If i use the code like below I believe it would still return the right result?

This below matches all the char in both space and word so I believe there is no need of checking “-”.
for (let i = 0; i < space.length; i++) {
if (space[i] !== word[i]) {
return false;