In order to address an issue, I implemented the following two lines of code:
MyString = div.getAttribute('data-type') || div.getAttribute('data-id');
MyString = MyString.replace('RemoveThis', '');
Although the code is functional, I noticed that I am repeatedly using the variable MyString. I attempted to condense it with this snippet:
MyString = div.getAttribute('data-type') || div.getAttribute('data-id').replace('RemoveThis', '');
Unfortunately, the condensed code did not work as expected.
Do you have any suggestions on how I can avoid repeating MyString?
Additionally, would the proposed solution be approved in a code review?