Stage 2 — why doesn't replace change answer?
OP
I called answer.replace(",", ".") but answer still has the comma.
I called answer.replace(",", ".") but answer still has the comma.
Comments 4
Log in to join the discussion.
Log in Create accountStrings are immutable —
replace()returns a new string and leaves the original untouched. You need to store the result (or assign it back toanswer). That's exactly what stage 2 is making you notice withanswer_after.Aha, so the method gives me a new value instead of editing.
The "Strings don't change" challenge is all about this.
As a German user, thank you for this challenge. Half the apps I use crash on "42,5" 😄