# Applab Data coding

**URL:** <https://forum.code.org/t/applab-data-coding/33342>\
**Category:** CS Principles\
**Tags:** csp\
**Created:** [September 16, 2020, 12:59pm UTC](https://forum.code.org/t/applab-data-coding/33342 "2020-09-16T12:59:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![e.fat](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@e.fat](https://forum.code.org/u/e.fat)\
**Post date:** [September 16, 2020, 12:59pm UTC](https://forum.code.org/t/applab-data-coding/33342/1 "2020-09-16T12:59:39Z")

</div>

Hi,

I am going to assign the Post AP Data tools 19-20 to my students, but before that I wanted to test it out and see the program. It is really good. I decided to do a quick app of what I will get the students to do at the end of the semester.

I am not sure if the code is correct, as I have a yellow triangle. Otherwise it works and I can see the data.

Here is the app I quickly built:

> **[Check out what I made](https://studio.code.org/projects/applab/K2V6Fo-j3o4yOk0QSKT6CaXSwbdirFFiXO1QTf45SRk)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

**Author:** ![terence.stone25](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/terence.stone25/32/5124_2.png) [@terence.stone25](https://forum.code.org/u/terence.stone25)\
**Post date:** [September 16, 2020, 1:46pm UTC](https://forum.code.org/t/applab-data-coding/33342/2 "2020-09-16T13:46:24Z")

</div>

@e.fat The yellow triangle usually indicates a warning, such as an unused variable.

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [September 16, 2020, 2:24pm UTC](https://forum.code.org/t/applab-data-coding/33342/3 "2020-09-16T14:24:07Z")

</div>

You don’t need the record parameter to the function expression because you don’t use it.

---

<div class="post-metadata">

**Author:** ![e.fat](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@e.fat](https://forum.code.org/u/e.fat)\
**Post date:** [September 16, 2020, 10:58pm UTC](https://forum.code.org/t/applab-data-coding/33342/4 "2020-09-16T22:58:15Z")

</div>

Thanks for that, but why don’t I need it exactly?

Though is the code correct?

---

<div class="post-metadata">

**Author:** ![e.fat](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@e.fat](https://forum.code.org/u/e.fat)\
**Post date:** [September 17, 2020, 12:10am UTC](https://forum.code.org/t/applab-data-coding/33342/5 "2020-09-17T00:10:34Z")

</div>

I have added a new column in my table where the user selects its Gender. However when I code and check my data it does not work properly. When the user selects their gender and type in there favourite food, it should be appear on the data in one row, however it appears in two.

As an example:

Favourite Food: Gender:  
Pizza Male

I want it to appear like this, but can’t seem to work it out.

> **[Check out what I made](https://studio.code.org/projects/applab/K2V6Fo-j3o4yOk0QSKT6CaXSwbdirFFiXO1QTf45SRk)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [September 17, 2020, 2:23am UTC](https://forum.code.org/t/applab-data-coding/33342/6 "2020-09-17T02:23:10Z")

</div>

You don’t use it within the function you have defined. So you don’t need to pass it as a parameter.

The code is correct. App Lab uses something called a lint remover. What that does is look for possible mistakes. Not using a parameter is a possible mistake so you get a warning. It isn’t an actual error.

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [September 17, 2020, 2:36am UTC](https://forum.code.org/t/applab-data-coding/33342/7 "2020-09-17T02:36:29Z")

</div>

It does what it is coded to do, but you coded it to do something you don’t want. It happens more often than you think. There is no error.

What it does is have two ways to create a record in your database. One way is to change the gender drop down. That puts a record into the database with the value male, female, or Please choose one. Foodtype will be undefined.

The second way is to push the Next button. That creates a record in your database with foodtype set to whatever is in txtinput. Gender will be undefined.

I suspect what you wanted is to have only one way to create a record with both gender and foodtype set. The way you would do that is to remove the onEvent from dropdown2. Change the onEvent for the button to test if there is a valid value in dropdown2, meaning not Please choose one. You could also check to see if txtinput is not blank. If so then create a record with both the dropdown2 and the txtinput values else don’t and possibly make a text box visible that says either gender or favorite food is blank.

---

<div class="post-metadata">

**Author:** ![e.fat](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@e.fat](https://forum.code.org/u/e.fat)\
**Post date:** [September 17, 2020, 3:06am UTC](https://forum.code.org/t/applab-data-coding/33342/8 "2020-09-17T03:06:53Z")

</div>

Yes I want to create a record with both gender and foodtype set. How would that code look?

---

<div class="post-metadata">

**Author:** ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)\
**Post date:** [September 17, 2020, 5:11pm UTC](https://forum.code.org/t/applab-data-coding/33342/9 "2020-09-17T17:11:32Z")

</div>

> **[Check out what I made](https://studio.code.org/projects/applab/_QVWLIUG1vER1vqPijm-H1Tb9BTvnbt8mwk6E4LYsEQ)**
>
> I wrote the code myself with Code.org
