0

  const trimEnd = str => str.endsWith('/') ? str.slice(0, -1) :
                            str;


                        const filterWithValue = str => str.length;

Why wouldnt this work on a OS Big Sur chrome or Safari browser, but on windows or an ios 10 and below? How can I solve

I have a piece of code that works fine on OS10 browsers (chrome, safari, firefox) but not on os11 big sur browsers? Seems very odd since these are modern?

Vzupo
  • 1,388
  • 1
  • 15
  • 34
  • What error message are you getting? [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith#browser_compatibility) suggests that Safari has supported `endsWith` since 2015. – edemaine Jul 22 '21 at 18:56
  • cant read property .endsWith of undefined – Vzupo Jul 22 '21 at 19:00
  • It's not clear what your issue is because you haven't provided enough code to reproduce the issue. See https://stackoverflow.com/help/minimal-reproducible-example – jsejcksn Jul 22 '21 at 19:02
  • @Vzupo are you sure you are passing a string to `trimEnd`? – sschwei1 Jul 22 '21 at 19:32
  • str on mac OS 11 says undefined but OS 10 and windows its fine – Vzupo Jul 22 '21 at 19:37
  • @Vzupo given your error message, the code you posted is fine -- the issue is that the input `str` is `undefined`. Please show the code that actually calls your `trimEnd` function. – edemaine Jul 22 '21 at 21:38

0 Answers0