Guessing Game explainer

The aim of this puzzle: Check another shell to see if the pea is under it and print a clue.

Walkthrough of the solution: The first line of code creates a variable called pea. It’s storing a random value – either 1, 2, or 3. This number represents which shell the pea is under. The if statement check if the value of pea and sees if it is NOT equal to 1. If pea is 2 or 3, then it prints, “Not under shell 1”.

You need to make a similar check for another shell – let’s do shell 3. We need another if statement below the original one but not inside of it. We want this check to happen after we’ve checked shell 1. To see if the pea is not under shell 3, we use pea !== 3. Now we know that the code inside the curly brackets of the if statement will only run if pea is not equal to 3. We can add a print() between the curly brackets that says, “Not under shell 3”.

Sample code solution:
(Tap below to reveal)

var pea = pickRandom([
if (pea !== 1) {
    print('Not under shell 1');
if (pea !== 3) {
    print('Not under shell 3');

JavaScript Concepts: Code Block (if statement), Calling Functions, Identifiers, Variable Declaration
Grasshopper Concepts: pickRandom(), print()


What does !== Mean?? I think we should be told what dies that mean


!== means ‘does not equal’. It checks if two values are not equal to each other. For example, since 5 is not equal to 4, 5 !== 4 would be true. Whereas 4 !== 4 would be false.

Another way to think of if, is that it’s the opposite of ===, which checks if two values are equal to each other.

H :slight_smile:


I have been doing the exact thing on the explanation but I have been getting maximum call stack size exceeded


Hi @Bryan_Chen,

This is a bug on our side — your code is correct! Sorry you’ve hit up against this issue, we’re still working to figure out what’s going wrong in these scenarios, so we can create a fix.

In the meantime, if you hard-close Grasshopper, re-open, then run your code again it should solve the puzzle. Let me know if that doesn’t fix things, though!

Thanks for flagging this,
H :slight_smile:


I agree that this puzzle needed better explanation in the beginning. The hint wasn’t much help. This is meant for beginners… Should be explained to us like we have no previous understanding.


Am also getting it wrong but is the same answer to yours.


Why isn’t it working?


The print('Not under shell 3') should be between the curly brackets {} of the if (pea !== 3).

The way your code is now, the 2nd If Statement will check if pea is not 3, but won’t do anything if that test is true. And the bottom print statement will always print.




It’s weird, in case I add all 3 options as “if” constraints I receive three time “not under …”. I would have expected only two replies since the pea must be under under one of the shells. Or is my code wrong? Interestingly, I managed to pass the challenge (might be I used the !== function at least).


1 Like

The pea will be a number, but your If Statements are checking against strings.

2 !== '2’ is true because the 1st is a number and the 2nd is a string. If you delete the strings and add new num values, it should work as you expect.



Thx for the quick help! It keeps up my motivation to go on learning :wink:


Me pasa igual y le doy esa respuesta y nada.

Hey there, post a screenshot of your code and I can take a look and give you some help.



it means NOT EQUAL TO

1 Like

Its still not working for me, is there a possibility for me to skip and get on to the next challenge please

!== means not equal operator, which checks if the value on left side is not equal to the value on right side. For example, 85 !== 2 will return true, whereas 55 !== 55 return false. This operator is the same to the equality === operator except the !== operator checks if a left-side value is not equal to right-side value, while the === operator checks if a left-side value is equal to right-side value. For example with the code:

if (55 !== 28) {
    console.log("True!"); /* This prints "True!"
 since the test is true. */

if (68 === 24) {
    console.log("False!"); /* This will never print
 "False!" since the test is false. */

In the meantime, you can rewrite my code in the code playground.

P :slightly_smiling_face:

i have beeen stuck in this stage because i have given right answer as you shown but it dosent work anyway. he said to statement if for pea 3. but i already do it. please help me to fix the bux

heres the screenshot of that bug. i tried and give the right answer but didnt work. i wish that you can fix the buxguessing game problem

i hav done this it aint working someone plz tell me what i am doing wrong

1 Like