0

I have a statement like

bicCode.ToUpper().TrimEnd('X');

I want to rewrite this in javascript

response.data.toUpperCase().??

How to write trimend function in javascript?

Navoneel Talukdar
  • 4,393
  • 5
  • 21
  • 42
  • 1
    @Equalsk that's not really the same behaviour as TrimEnd. – David Sherret Feb 02 '17 at 14:50
  • Why don't you try the following: http://codereview.stackexchange.com/questions/28464/trim-certain-characters-from-a-string-in-javascript – John Adams Feb 02 '17 at 14:50
  • 1
    @DavidSherret You're right I worded it badly but it wasn't meant to directly answer the question, it was more a problem that OP showed no effort. I'm not even a JavaScript guy but after reading that thread I wrote TrimEnd in about 2 minutes: https://jsfiddle.net/cgvw5x9e/ and if I can do it then OP can. – Equalsk Feb 02 '17 at 15:28
  • this isn't a duplicate... – Jakotheshadows Jun 14 '17 at 17:11
  • @Equalsk you should post that as an answer. An answer has already been accepted, but it is only the empty argument overload of TrimEnd, your fiddle adds the missing piece – Jakotheshadows Jun 14 '17 at 19:49
  • 1
    @Jakotheshadows Can't answer locked posts. – Equalsk Jun 14 '17 at 19:51
  • 1
    yeah, god forbid people be able to easily find useful information on a site designed to help people do just that. Better to make a superficial examination of the post, incorrectly conclude that its a duplicate, and close it thus wasting the productivity of the people (including yourself) who contributed to comments and answers and robbing the OP of a good question. – Jakotheshadows Jun 22 '17 at 13:59

1 Answers1

3

This should work:

response.data.toUpperCase().replace(/\s+$/g, '');