# Homeyscript and lodash

**URL:** <https://community.homey.app/t/homeyscript-and-lodash/75323>\
**Category:** Developers\
**Created:** [January 19, 2023, 4:28pm UTC](https://community.homey.app/t/homeyscript-and-lodash/75323 "2023-01-19T16:28:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 19, 2023, 4:28pm UTC](https://community.homey.app/t/homeyscript-and-lodash/75323/1 "2023-01-19T16:28:53Z")

</div>

I am trying to use lodash. But i am stuck how to rewrite a bit of my script. is someone willing to show me how to rewrite this peace of code.? That way hopefully i can sorten out the rest.

```auto
var count = 0;
var number = 0;

while(count <= sort.length -1)
{
var sortDay = global.get(sort[count] +'Day'+currentYear +currentMonth);//huidige dag opslaan
if(!Array.isArray(sortDay) || !sortDay.length)//als array niet bestaat
{
sortDay = Array(daysInCurrentMonth).fill(0);
sortDay.splice(currentDay -1,1,+eval(sortDay));
global.set(sort[count] +'Day' +currentYear +currentMonth, sortDay);
var sortDay = global.get(sort[count] +'Day'+currentYear +currentMonth);//huidige dag opslaan
console.log((number +1) +' ' +sort[count] +'Day' +currentYear +currentMonth +' is ' +sortDay);
}
console.log((number +2) +' '+sort[count] +'Day is: '+eval(sortDay));
sortDay.splice(currentDay -1,1,eval(sort[count]));
console.log((number +3) +' '+sort[count] +'Day' +' is: '+eval(sort[count]));
global.set(sort[count] +'Day' +currentYear +currentMonth, sortDay);
console.log((number +4) +' ' +sort[count] +'Day' +currentYear +currentMonth +' is ' +sortDay);
sortDay = global.get(sort[count] +'Day' +currentYear +currentMonth);
console.log((number +5) +' ' +sort[count] +'Day' +currentYear +currentMonth +' is ' +sortDay);
sortDay = sortDay[currentDay -1];
}

```

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [January 19, 2023, 9:35pm UTC](https://community.homey.app/t/homeyscript-and-lodash/75323/2 "2023-01-19T21:35:52Z")

</div>

Can you also share `sort`?

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 19, 2023, 9:54pm UTC](https://community.homey.app/t/homeyscript-and-lodash/75323/3 "2023-01-19T21:54:14Z")

</div>

sort = [‘water’, ‘gas’, ‘peak’, ‘offPeak’, ‘producedPeak’, ‘producedOffPeak’, ‘power’]
