# ES6: Use Destructuring Assignment to Assign Variables from Objects issues

**URL:** <https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822>\
**Category:** General\
**Created:** [September 11, 2019, 10:14pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822 "2019-09-11T22:14:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KnackHash](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/knackhash/32/124342_2.png) [@KnackHash](https://forum.freecodecamp.org/u/KnackHash)\
**Post date:** [September 11, 2019, 10:14pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/1 "2019-09-11T22:14:35Z")

</div>

I cannot get past this tutorial.

Below is my solution. It is saying I haven’t used destructuring. I’m not sure what I’m doing incorrectly. I thought I had structured things exactly as was shown in the demonstration and hint.

```auto
const AVG_TEMPERATURES = {
  today: 77.5,
  tomorrow: 79
};

function getTempOfTmrw(avgTemperatures) {
  "use strict";
  // change code below this line
  const { tomorrow : tempOfTomorrow, today : tempOfToday } = AVG_TEMPERATURES;// change this line
  // change code above this line
  return tempOfTomorrow;
}

console.log(getTempOfTmrw(AVG_TEMPERATURES)); // should be 79

```

---

<div class="post-metadata">

**Author:** ![ptrvenckus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ptrvenckus/32/118195_2.png) [@ptrvenckus](https://forum.freecodecamp.org/u/ptrvenckus)\
**Post date:** [September 11, 2019, 10:28pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/2 "2019-09-11T22:28:56Z")

</div>

Parameter of function getTempOfTmrw is avgTemperatures, not AVG\_TEMPERATURES. Also you don’t need to think about temperature of today, only about temperature of tomorrow

---

<div class="post-metadata">

**Author:** ![KnackHash](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/knackhash/32/124342_2.png) [@KnackHash](https://forum.freecodecamp.org/u/KnackHash)\
**Post date:** [September 11, 2019, 10:33pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/3 "2019-09-11T22:33:11Z")

</div>

The conditions to pass the assessment are:

- `getTempOfTmrw(AVG_TEMPERATURES)` should be `79`

- destructuring with reassignment was used

I still don’t see why this solution doesn’t pass this specific test.

---

<div class="post-metadata">

**Author:** ![ptrvenckus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ptrvenckus/32/118195_2.png) [@ptrvenckus](https://forum.freecodecamp.org/u/ptrvenckus)\
**Post date:** [September 11, 2019, 10:36pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/4 "2019-09-11T22:36:02Z")

</div>

AVG\_TEMPERATURES is outside of function’s scope

---

<div class="post-metadata">

**Author:** ![KnackHash](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/knackhash/32/124342_2.png) [@KnackHash](https://forum.freecodecamp.org/u/KnackHash)\
**Post date:** [September 11, 2019, 10:37pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/5 "2019-09-11T22:37:12Z")

</div>

But AVG\_TEMPERATURES is what the test asks for. Isn’t the variable tested by a function able to be anything so long as it follows the data structure expected by the function?

---

<div class="post-metadata">

**Author:** ![KnackHash](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/knackhash/32/124342_2.png) [@KnackHash](https://forum.freecodecamp.org/u/KnackHash)\
**Post date:** [September 11, 2019, 10:39pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/6 "2019-09-11T22:39:00Z")

</div>

```auto
function getTempOfTmrw(n) {

```

K changed the function to this, and it still processes AVG\_TEMPERATURES just fine.

---

<div class="post-metadata">

**Author:** ![ptrvenckus](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ptrvenckus/32/118195_2.png) [@ptrvenckus](https://forum.freecodecamp.org/u/ptrvenckus)\
**Post date:** [September 11, 2019, 10:43pm UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/7 "2019-09-11T22:43:17Z")

</div>

First you are writing a function with parameter avgTemperatures and after you are calling that function already with AVG\_TEMPERATURES. Output inside of console is 79. If your parameter is n, inside of function is visible n, but AVG\_TEMPERATURES also is not visible

---

<div class="post-metadata">

**Author:** ![eoja](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/eoja/32/135387_2.png) [@eoja](https://forum.freecodecamp.org/u/eoja)\
**Post date:** [September 12, 2019, 12:17am UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/8 "2019-09-12T00:17:28Z")

</div>

> [@KnackHash](#):
>
> ```auto
> function getTempOfTmrw(n) {
> 
> ```
> 
> K changed the function to this, and it still processes AVG\_TEMPERATURES just fine.

The problem is that you are not using the function parameter. Rather you directly use the variable. To pass the test you need to use the function parameter. If you change the parameter like this `function getTempOfTmrw(n)`, then you, for example, use n within your function. But to pass the test you need to use the parameter they originally provided you with.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:28am UTC](https://forum.freecodecamp.org/t/es6-use-destructuring-assignment-to-assign-variables-from-objects-issues/313822/9 "2021-01-17T09:28:23Z")

</div>


