Trying to put a limit on the length of a javascript object


#1

Hi All,

I’m doing the javascript calculator project and I’m trying to stop numbers entered into my calculator from running out of the display div.

This is what I have so far:

if (result.toString().length > 16) {
result =
};

I don’t know how to cap the length of result at 16 characters.


#2

hey,

you can try overflow rather than clearing the result; it will clip the overflow.

W3Schools - CSS