# Variables are a struggle

**URL:** https://forum.code.org/t/variables-are-a-struggle/39139
**Category:** Unit and Lesson Discussion
**Tags:** csd-unit-3
**Created:** [March 13, 2024, 2:39pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139 "2024-03-13T14:39:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hilld](https://avatars.discourse-cdn.com/v4/letter/h/71e660/32.png) [@hilld](https://forum.code.org/u/hilld)
#### Post date: [March 13, 2024, 2:39pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139/1 "2024-03-13T14:39:44Z")

</div>

My students are struggling with variables. The concept of a container that temporarily stores information seems to lose them. Also, they get lost when they are asked to call the variable in their program.

Any help would be appreciated.

---

<div class="post-metadata">

### Author: ![varrience](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/varrience/32/8042_2.png) [@varrience](https://forum.code.org/u/varrience)
#### Post date: [March 13, 2024, 4:15pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139/2 "2024-03-13T16:15:23Z")

</div>

to understand variables you must also understand scope and datatypes. though since assignment of data isn’t as important all you really have to worry about is how it’s assigned and when it can be used

> Why are variables useful?

well when your having a conversation would you like the person your talking to remember your response or forget it and ask the same question again? variables help us reduce the amount of times we have to repeat ourselves within a given program and save us time if we have to make any changes including the variable were using

> Are variables temporary or permanent storage?

variables are temporary as it will only be able to store information while running, if it is reset for any reason it will lose all of it’s memory and will **only** start storing info once it is running again and it will **not** remember the previous value it was set at; it will be the value it’s first assigned at

> What is a container? And what does it have to do with variables?

a container is exactly what it sounds like, your program is like a big box, of which the starting point is considered “global” of which all rooms have access too. But like with all things you have some things that you’d rather have kept private right? so we create a smaller container like a lock-box or a diary in your room that the bigger container can’t access because it’s in a “private” container that you should only have access too. let’s show an example since this is a bit hard to visualize

```auto
// gloabl container
var a = 0;
// private container
function diary() {
var b = 1;
}
diary();
// global variable
console.log(a);
// errors out since it doesn't have access
console.log(b);

```

as you can see structuring your code for certain things is important and this is a bit more advanced implicit knowledge that you may run into later when making more complex programs

Hope this helps: Varrience

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [March 14, 2024, 2:31pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139/3 "2024-03-14T14:31:36Z")

</div>

@hilld,

Great points made by @varrience. I have also found [this video](https://www.youtube.com/watch?v=G41G_PEWFjE) helpful when introducing variables. I like that it uses score and lives - since every student knows how often these pieces of data changes in a game.

There is also this [unplugged lesson.](https://studio.code.org/s/course4/lessons/4/levels/1) I haven’t used it but it may be helpful if students are struggling with the concept of variables.

Good luck!  
~Michelle

---

<div class="post-metadata">

### Author: ![GordonBrune](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gordonbrune/32/4752_2.png) [@GordonBrune](https://forum.code.org/u/GordonBrune)
#### Post date: [March 14, 2024, 2:44pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139/4 "2024-03-14T14:44:30Z")

</div>

Curious, is there one doc where all the [code.org](http://code.org) UNPLUGGED lessons are listed?

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [March 14, 2024, 3:17pm UTC](https://forum.code.org/t/variables-are-a-struggle/39139/5 "2024-03-14T15:17:32Z")

</div>

@GordonBrune -

There is [this one](https://code.org/curriculum/unplugged). 😊
