# Beginner questions on IF expressions and wildcard usage in function node

**URL:** <https://discourse.nodered.org/t/beginner-questions-on-if-expressions-and-wildcard-usage-in-function-node/80999>\
**Category:** General\
**Created:** [3 September 2023 11:43 UTC](https://discourse.nodered.org/t/beginner-questions-on-if-expressions-and-wildcard-usage-in-function-node/80999 "2023-09-03T11:43:38Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![AleXSR700](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alexsr700/32/41161_2.png) [@AleXSR700](https://discourse.nodered.org/u/AleXSR700)\
**Post date:** [3 September 2023 12:18 UTC](https://discourse.nodered.org/t/beginner-questions-on-if-expressions-and-wildcard-usage-in-function-node/80999/7 "2023-09-03T12:18:20Z")

</div>

Okay, I got a step closer.  
I cannot check for the key directly but first need to ensure that the object is actually present.

```auto
if (msg.payload.ENERGY !== undefined) {
    var msg = { payload: msg.payload.ENERGY['Power'] };
    return msg;
}

```

EDIT:  
And in a second step then check the key.

This seems to work:

```auto
if (msg.payload.ENERGY !== undefined) {
    if (msg.payload.ENERGY['Power'] !== undefined) {
        var msg = { payload: msg.payload.ENERGY['Power'] };
        return msg;
}
}

```

Now I need to figure out the wildcard problem.

---

_[View the full topic](https://discourse.nodered.org/t/beginner-questions-on-if-expressions-and-wildcard-usage-in-function-node/80999)._
