More explanation needed for the 'pass-by-reference'
Hello everyone, I was checking the exercise in the link above and I was doing some tests.
I was just wondering regarding the concept of pass-by-reference, and I got a bit confused

So why would this code change the global and local variable

let array = ['why', 'you', 'no', 'change', '?'];
// attempting to mutate the array by removing the last index
function changeArr(arr) {
  console.log("inside: ", arr);
console.log("outside: ", array);
//inside:  [ 'why', 'you', 'no', 'change' ]
//outside:  [ 'why', 'you', 'no', 'change' ]

while this code only changes the local variable

let variable = "Hello"
//attempting to change the variable using the pass-by-reference
function changeStr(text) {
  text = 'Bye';
  console.log('Inside: ' + text);

console.log("outside: " + variable);
//Inside: Bye
//outside: Hello

appreciate your assistance on this :raised_hands: