It must be super simple, but I'm completely stuck.
var arr = ["ABCD", "asda12"];
var a = arr[0];
a[1] = 'S';
console.log(a[1]);
It logs "B" and I expect "S", why can't I do it this way?
It must be super simple, but I'm completely stuck.
var arr = ["ABCD", "asda12"];
var a = arr[0];
a[1] = 'S';
console.log(a[1]);
It logs "B" and I expect "S", why can't I do it this way?
In your code, "a" is a string and you can't change it's value in that way. You can try setting "a" as an array, then you can change it with the way you do:
var arr = ["ABCD", "asda12"];
var a = [...arr[0]];
a[1] = 'S';
console.log(a[1]);