Using JS to control math-resultant decimal overruns

Got some math going on in my game and some of the operations are giving me crazy results, such as an age of 23.5532221 or whatever. I want them down to a single digit (such as 23.5 or whatever).

Tried this but it did not work. Is there a way (either in squiffy or JS) to reduce this?

[[next]]:

    var work;
    
    set("test", 12.123);
    work = get("test");
    work.toFixed(1);;
    set("test",work);
    
{test}

The toFixed method returns a value, it doesn't modify the number it was called on.

So you want:

[[next]]:

    var work;
    
    set("test", 12.123);
    work = get("test");
    work = work.toFixed(1);
    set("test",work);
    
{test}

Many thanks. That's what I was looking for. I didn't understand the usage.


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums