# Tip of the day never displays the first tip from array

**URL:** <https://discourse.stonehearth.net/t/tip-of-the-day-never-displays-the-first-tip-from-array/9263>\
**Category:** Resolved Reports\
**Tags:** resolved\
**Created:** [December 24, 2014, 3:53am UTC](https://discourse.stonehearth.net/t/tip-of-the-day-never-displays-the-first-tip-from-array/9263 "2014-12-24T03:53:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonzoid](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/jonzoid/32/44593_2.png) [@jonzoid](https://discourse.stonehearth.net/u/jonzoid)\
**Post date:** [December 24, 2014, 3:53am UTC](https://discourse.stonehearth.net/t/tip-of-the-day-never-displays-the-first-tip-from-array/9263/1 "2014-12-24T03:53:22Z")

</div>

I thought something looked fishy about this during the stream. Is there a category for future bugs? 😉

 ![](https://us1.discourse-cdn.com/flex022/uploads/stonehearth/original/2X/9/97b329a6d959ca93caf15d53fedb341f61c79157.JPG)

`random` will never be 0. That means the first tip in your array will never display.

Try it:

**Gives 1, 2, 3 as possible values (what your code is doing)**  
`Math.ceil(Math.random() * (['a','b','c','d'].length - 1));`

**Gives 0, 1, 2, 3 as possible values (use floor and remove the -1)**  
`Math.floor(Math.random() * (['a','b','c','d'].length));`

Merry Christmas, @Tom!

---

<div class="post-metadata">

**Author:** ![cr1t1calxt](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/cr1t1calxt/32/15014_2.png) [@cr1t1calxt](https://discourse.stonehearth.net/u/cr1t1calxt)\
**Post date:** [December 24, 2014, 4:14am UTC](https://discourse.stonehearth.net/t/tip-of-the-day-never-displays-the-first-tip-from-array/9263/2 "2014-12-24T04:14:44Z")

</div>

Good catch! Those pesky indexing errors!

---

<div class="post-metadata">

**Author:** ![SteveAdamo](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/steveadamo/32/13955_2.png) [@SteveAdamo](https://discourse.stonehearth.net/u/SteveAdamo)\
**Post date:** [December 24, 2014, 5:04am UTC](https://discourse.stonehearth.net/t/tip-of-the-day-never-displays-the-first-tip-from-array/9263/3 "2014-12-24T05:04:24Z")

</div>

nice work @jonzoid! I’ve embedded your feedback directly into his post, as he will likely not see @ references to his forum name… 😉
