Update Your Progress explainer


#1

The aim of this puzzle: To add to and update the variable elevation, then print out the new value for elevation.
Review concepts: The achievement ‘Used Math Operators’ unlocks the ability to complete this puzzle.
Review puzzles: Try taking another a look at the puzzle ‘Simply More Math’ to see how to add to a variables value then print it out using print().
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: Calling Functions, Binary Expression (+)
Grasshopper Concepts: print()

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

var elevation = 100;

#3

I’m putting in the correct code and nothing is happening.


#4

I don’t get it either. I’ve done just what that stood, and I gets the right answer, but it still is wrong…?


#5



#6

Technically my attempt worked but it didn’t pass lol
.


#7

Mh… what‘s wrong here? I don‘t get it…

![image|281x499](upload://mR2iGfRFiFhwJgCcHMOMMFFtcaI.jpg)

#8

@Midnitewolfy Looks like you did the same thing as Joseph! lol
The puzzle is looking to update the elevation variable and THEN print the new value as two separate lines.
Take a look at Momo’s screenshot to view the answer.

@hagr If you leave off the single quotes around your screenshot, the board will automatically put your image in your post rather than just the code. But I was able to view your screenshot in my post preview and looks like you’re having the same issue as Joseph and Midnite. The puzzle is looking for two separate lines: update the variable THEN print the new value. :slight_smile:


#9

Any thing wrong with this method?


#10

Hey @Fuzzi,

Although this method prints out the values correctly, the value inside elevation hasn’t been updated.

This means, if you add a third line of code of print(elevation) at the end, it would print out 100, rather than 555. Since the aim of this puzzle is to add to the value elevation, using print(elevation + 455) doesn’t solve it.

H :slight_smile:


#11

For those having problems this thread didn’t really help me so I had to figure it out and now I’m here to help so here you go:

First things first. It’s not simple math, it’s actually “Simply More Math” in the operators section.

Now with that said here’s the point of confusion.
If we refer to “Simply More Math” we’ll find that we had to write the equation and then print it. So:
var y = 10;
y = y + 7;
print(y)

Gives us a print out of 17

Now if we apply this to our current problem with elevation:

print(elevation);
elevation = elevation + 455
print(elevation)

This is the code that’s hanging us up because we’re not realizing that we’re supposed to do the equation outside of the print codes, thereby hiding the calculation that is taking place. I hope this is helpful in explaining the issue.

EDIT: Hey so as an after thought… The reasoning of this, because i believe reasoning will help to show why it had to be done this way, is that the equation updates the code. This is crucial for later when we are doing more extensive coding. Essentially as @RetroJLO was pointing out, this is updating the variable “elevation” if for instance later we added another 300 to the elevation, you would want it to add to the already calculated total, not the initial 100. If it’s not done as this code shows that’s what would happen, so it’s important to understand this.


#12

This was helpful! Thank you. This puzzle makes zero sense.


#13

Hey @jmal,

Thanks for catching that — I’ve updated it now.

And thanks for adding such a detailed explanation!

H :slight_smile:


#14

The ‘hidden code’ is something that one should be aware of and I don’t know how anyone could know that from the exercise? I could not figure out why it was not necessary to assign an initial value to “elevation”.


#15

I can’t figure it out


#16

that works


#17

Hmm I misunderstood the code and as far as I know this is wrong, but I got lesson complete… just wanted to inform about this.