Stuck with math problem..... (Ai2-based Block programming Mobile Csp)

Hey all,

I was wondering if someone could help me with answering this question. It is from Mobile CSP's course, but the blocks and the code all are embedded from AI2's source code, so the logic should be the same.

Define a procedure called increment(X) that adds X to the global variable Z. In other words, if Z equals 5 before you call this procedure and you call increment(10) , then 10 will be added to Z making its value 15 after the procedure finishes.

Hints
  • Use the to-procedure block in the Procedures drawer and name it increment.
  • Use the mutator to add a parameter to the procedure definition.
  • In the do slot, you will need to construct a statement that adds the parameter x's value to the variable Z.

Screenshot-
Screenshot 2021-02-02 at 9.11.47 AM
Click the screenshot to go to the link.

No matter what i do, I always get that runtime error- ReferenceError: increment is not defined. Does anyone know what to do? Or what I'm doing wrong?

Note that the procedures do not need an event handler to run- the site runs the code when you click check answer.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.