0

Here my array :

let model = ["xxx","xxx"];

I want to replace the second 'x' in the string of the second element of the array by 'o'.

I tried this :

let model = ["xxx", "xxx"];

console.log(model[1][2])
// -> output : x -> OK

model[1][2] = model[1][2].replace('x', 'o')

console.log(model);
// -> output : ["xxx", "xxx"] -> ???

I tried this too :

let model = ["xxx", "xxx"];

console.log(model[1][2])
// -> output : x

model[1][2] = 'o'

console.log(model);
// -> output : ["xxx", "xxx"]

Why is not working ? Thank you !

Calvin Nunes
  • 6,376
  • 4
  • 20
  • 48
Tony S
  • 491
  • 6
  • 26

0 Answers0