Try this on ( 'change:hunger' , function () { getAttrs ([ 'hunger' ], function ( values ) { const hunger = parseInt ( values . hunger ) | 0 ; let hunger_text = '' ; if ( hunger >= 10 ) { hunger_text = "text 2" ; } else if ( hunger >= 5 ) { hunger_text = "text 1" ; } else { hunger_text = "whatever is below 5" ; } setAttrs ({ hunger_text : hunger_text }); }); }); When building an if statement, you need to plan the order carefully. This says anything 10 or above, then anything 5 or above, then anything else. An if statement stops at the first condition that matches. So if I had the >=5 test first, the code would skip the rest of the branches of the if statement, and would include the 10+ group.