Ad
  • Custom User Avatar

    Nowhere is it mentioned that input should not be mutated.

    If it's because mutating the input breaks the tests, then the test code is subpar and they should be written so that mutating the input does nothing.

  • Custom User Avatar

    "Variables" are just name tags, they can point to the same object, like in JS:

    var a = [];
    var b = a; // a and b are the same object
    a.push(1); // both a and b are [1] now
    

    If you want to work with them you need to copy every object (read: anything that's not a primitive value):

    var a = [];
    var c = a.slice(); // c is a shallow copy of a, so different object
    a.push(1); // c remains []
    
  • Custom User Avatar

    I am receiving this error: "Your function returns the correct result. However, it modifies the input arrays. Try not to change them. They might be used somewhere else."

    My solution worked for 100% of tests but is still overall failing here. My solution creates new variables from the input arrays. Any tips on where I am failing?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    this is what i understand is going on:

    Lyanna shared 50 (or put in 50) and then borrowed (or took out 500). so in total Lyanna borrowed (took out) 450. but the 'kitty' is shared 50/50, so half of what Lyanna took out is for her to use, and the other half (225) should be for Elia. So Lyanna owes Elia that 225. hopefully that makes sense...

  • Custom User Avatar