# Converting bit string to multiple boolean device attributes

**URL:** <https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708>\
**Category:** Help\
**Tags:** function-node, binary\
**Created:** [April 10, 2019, 3:38pm UTC](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708 "2019-04-10T15:38:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 10, 2019, 3:38pm UTC](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708/1 "2019-04-10T15:38:03Z")

</div>

I was able to convert a integer to a integer string such as 1001010.  
Now I want each of those binary positions to translate to individual boolean bit values to use as device attributes.  
Any suggestions?

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [April 10, 2019, 4:18pm UTC](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708/2 "2019-04-10T16:18:47Z")

</div>

I think the string node seems to be a good start

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [April 10, 2019, 4:33pm UTC](https://forums.losant.com/t/converting-bit-string-to-multiple-boolean-device-attributes/1708/3 "2019-04-10T16:33:29Z")

</div>

I found this on Stack Overflow that could be helpful for you. You should be able to do something like this in the Function Node.

> <https://stackoverflow.com/questions/7784620/javascript-number-split-into-individual-digits>

```auto
var bitString = 1001010;
var arrayOfDigitsAsStrings = bitString.toString().split('');
var arrayOfDigits = arrayOfDigitsAsStrings.map(Number)
console.log(arrayOfDigits); // [1, 0, 0, 1, 0, 1, 0]

```

Then, you can put that value back on the payload in the Function Node using:

```auto
payload.arrayOfDigits = arrayOfDigits

```

After that, you can use the Device State Node to report your values.
