frankcollins3 / fcc-mcsft-cSharp

FreeCodeCamp & Microsoft C# course:
1 stars 0 forks source link

using .Remove() && .Replace() together [5:50pm] #31

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: remove <div> tags and replace &trade with &reg in this picture, the div tags are removed, seemingly because the .Replace() method isn't being used. Screen Shot 2023-09-10 at 5 46 37 PM

error: .Remove() isn't eliminating the <div> when the .Replace() method is also called upon the string. Screen Shot 2023-09-10 at 5 49 05 PM

Screen Shot 2023-09-10 at 5 48 55 PM

proposed approach: callback function.

possible improvements:

frankcollins3 commented 1 year ago

makes more sense now. .Replace() would have to be called on the quantity string, not the input string. given this mention, if these are both string mutating values, a callback function is a good idea.

perform multiple mutations on the input string and then set quantity to be the final value that will be used [5:52pm]

explaining the going-ons further: quantity is redeclared to be the original string without the .Remove() being applied to it. [5:57pm]

that assumption is wrong. it does not mutate the original string. subsequent method invocations to be performed on {quantity} not {input}, and with reassignment not declaration Screen Shot 2023-09-10 at 5 58 01 PM [5:58pm]

frankcollins3 commented 1 year ago

have to clean it up but this works: Screen Shot 2023-09-10 at 5 59 44 PM Screen Shot 2023-09-10 at 5 59 34 PM [6:00pm]