# Linking random variables from a note box to a text box

**URL:** <https://cl.desmos.com/t/linking-random-variables-from-a-note-box-to-a-text-box/3610>\
**Category:** Questions\
**Tags:** validation, correctness\
**Created:** [August 24, 2021, 2:23am UTC](https://cl.desmos.com/t/linking-random-variables-from-a-note-box-to-a-text-box/3610 "2021-08-24T02:23:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yearby21](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@yearby21](https://cl.desmos.com/u/yearby21)\
**Post date:** [August 24, 2021, 2:23am UTC](https://cl.desmos.com/t/linking-random-variables-from-a-note-box-to-a-text-box/3610/1 "2021-08-24T02:23:57Z")

</div>

Hi.

I have a note box which contains this code.

r = randomGenerator()

a = r.int(8,20)  
b = r.int(5,9)

content: “Determine the volume of a cylinder with a height of {a} cm and a radius of {b} cm. Enter your final answer below and show your work on your submitted sheet”

I would like to then have a math input where the students type the answer, but I want the text input to check the answer for the students so that they know if they were correct. How do I link the randomly generated variables to the math input?

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [August 24, 2021, 4:32pm UTC](https://cl.desmos.com/t/linking-random-variables-from-a-note-box-to-a-text-box/3610/2 "2021-08-24T16:32:41Z")

</div>

You can access a variable created in Component 1 in Component 2 using this general format:

```auto
newVarNameHere = component1.script.varName

```

So if your note was Note1:

```auto
a= Note1.script.a
b=Note1.script.b

```

Then do whatever you need with a and b within your component. I generally prefer to create random variables where my calculations live, so if I decide to make changes I don’t need to switch back and forth between components. I’d personally use the above method to import into a note component, since they’re really just for display purposes, but it comes down to personal preference.
