skip to Main Content

I need help.. how can I print or display first 20 characters of the dataitem.message. For two days now I have been battling with this.

Please, see attached image

enter image description here

I have used dataItem.message.substring(0, 20) but it is still not working

2

Answers


  1. If dataItem.message’s type is anything but a string. The substring won’t help.
    Try to
    console.log(dataItem.message)
    And see what type it is.
    Otherwise it’ll be tough to help much more without also seeing where dataItem is created and updated in your code.

    Login or Signup to reply.
  2. Instead of passing the substrings as an argument to dataItem.message. I will suggest you use slice method. so instead of using dataItem.message.substring(0, 20) use dataItem.message.slice(0,20). I hope this helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search