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
I have used dataItem.message.substring(0, 20) but it is still not working
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
I have used dataItem.message.substring(0, 20) but it is still not working
2
Answers
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.
Instead of passing the
substrings
as an argument todataItem.message
. I will suggest you useslice
method. so instead of usingdataItem.message.substring(0, 20)
usedataItem.message.slice(0,20)
. I hope this helps!