The Final Ascent explainer


#1

The aim of this puzzle: To create an if statement nested inside a for…of loop, that loops through all the items in the equipment property’s array (inside the otherBackpack object) and tests if any of the items are equal to 'rope'. If an item is equal to 'rope', a celebratory message should be printed out.

Review concepts: The achievements ‘Created an If Statement’, ‘Used a For Loop’ and ‘Accessed a Property’s Value’ unlock the ability to complete this puzzle.

Review puzzles: Try taking another a look at the puzzles ‘Illustrated 8-Ball’ (creating an if statement), ‘Longer Rainbow’ (for loop with an array), ‘Image Decoder’ (if statement nested inside a for loop) ‘Make a Name for Yourself’ (accessing a property’s value) and ‘Going Green’ (accessing a property’s value in an if statement) to get an idea of how to tackle this puzzle.

Sample code solution:
(Tap below to reveal)

Since this is part of the final topic of the fundamentals course and it is testing your knowledge, there is no sample solution code.

JavaScript Concepts: Object Expressions, Member Expressions, Calling Functions, If Statements, Nested Blocks
Grasshopper Concepts: print()

Additional Code (hidden code that runs before the puzzle’s code):

var otherBackpack = {
    food: ['crackers', 'chocolate', 'raisins'],
    equipment: ['map', 'rope', 'compass'],
    clothing: ['hat', 'umbrella', 'boots']
};

The Final Ascent
Please help me to do this lesson
This is for them who stucked
What's wrong with my code?
Podem me ajudar
#2

I’m trying to enter if element === ‘rope’ but can’t seem to find the === ?


#3

I had the same issue, you need to scroll over in the commands window, there are more commands listed to the right


#4

Please help :roll_eyes:


#5


#6

Use if not if else :blush:


#7


Not perfect but work :smile:


#8

:grin::v:


#9


#10

turned easier than i thought it would be. Im sad that this is ending and its only have been 2 hours straight


#11

Very cool app! Ever think of developing desktop version for more controls and improved experience?

I’m not a total beginner but taking the beginner course and it’s a good refresher.


#12

plz help


#13

Galera separem um espaço para oq é o elemento rope é oq n é


#14

Hidden commands need to be explained better. Was pulling my hair out trying to figure out how to type

element === ‘rope’

I knew that was the command I needed but didn’t know you had to scroll over for === as I haven’t needed to scroll over until this test. Anyhow I got it now.


#15

Mă ajută cineva?


#16

I only see a glossery when I swipe to the right, I can’t find the (!==) either. I thought since there’s a little arrow at the end of (===) you might get the ‘not equal to’ button by long pressing, but that’s not working either. My code seems to be work except for that.


#17


Its doesn’t work, please help me


#18

Hi @Mugurel_Bere,

It appears that you are assigning a value to element even though element is already being given a value by the for…of loop. Besides that, it should be working as intended. :+1:

Hope this helps! :smile:


#19

Hey @elusive_cargo,

Mmm — this might be a bug if you’re not able to see the === symbol at all on the keyboard, even after scrolling. Would you be able to share a screenshot of your keyboard here, or send an email with a screenshot to grasshopper-support@google.com?

Sorry you’ve hit up against this issue.
H :slight_smile:


#20

This worked for me:

for (var element of otherBackpack.equipment)
{if (element===‘rope’){
print(‘i found some rope!’);}
else{print(‘a’+(element+‘not’));
}
}