Stage 2 — why doesn't replace change answer?

SamPriceOP

I called answer.replace(",", ".") but answer still has the comma.

2

Comments 4

Log in to join the discussion.

Log in Create account
  1. FreyaLreplies: 1

    Strings are immutable — replace() returns a new string and leaves the original untouched. You need to store the result (or assign it back to answer). That's exactly what stage 2 is making you notice with answer_after.

    6
    1. SamPriceOP

      Aha, so the method gives me a new value instead of editing.

      -1
    2. EmmaCodes

      The "Strings don't change" challenge is all about this.

      4
      1. LucasVD

        As a German user, thank you for this challenge. Half the apps I use crash on "42,5" 😄

        1