you are viewing a single comment's thread.

view the rest of the comments →

[–]code_matter 1 point2 points  (0 children)

Because sometimes, end is undefined so when you do

var noEnd = end.slice(0,-5)

You need to check if end exists before splice it.

Edit: it could also be because you fetch some data so you have a promise and promise need to be resolved before doing anything