javascript significant digits

for when you need to control what’s after those decimals, use toPrecision

 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision

Advertisements
javascript significant digits

i actually used CSS calc() in a real thing

so the input box has padding so the text inside of it isn’t right up against the box. in order to get the width of the dropdown menu to match the width of the input bar exactly, you have to add padding.

but when you add padding to the dropdown menu, the highlight doesn’t go all the way across.

SO you use calc(100% + 30px) to account for the 15px on either side of the input. BOOM.

i actually used CSS calc() in a real thing