loading...

re: Daily Challenge #50 - Number Neighbor VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Huh, this one was harder than I expected it to be... that probably means I missed something 🤣 Also, TIL that setting a character of a string in JS...
 

Strings in javascript are immutable, so even if you change a character using the [] notation, it always returns a new string.

This instead work as you expected

// The string is transformed into an Array
const arrString = [..."abc123"]
arrString[0] = "X"
// arrString is now ["X", "b", "c", "1", "2", "3"]
 

Makes sense - thanks! (forgot (or never really knew?) that strings in javascript were immutable)

code of conduct - report abuse