I have an array of items that is to be displayed inside a box of width 500px. Suppose the array is [john, johnbbab, johnabraham] and I need to display either the complete string or give ellipses accordingly if the text overflow. eg: If the box cannot hold the second item i.e johnbbab, the contents of the box will look like [john, ...].
The issue I'm facing is to determine how to render this depending on the width of the text assuming the fontsize is 10px.
PS: Need this to be done is Javascript