I am currently facing a challenge where I want to convert an entire word into capital letters. However, my approach seems to be encountering some issues. When it comes to individual letters, the toUpperCase method works perfectly fine.
var name = "gates";
for (var i=0; i< name.length; i++){
name[i] = name[i].toUpperCase();
}
name;
Interestingly, when I try using "hello world".toUpperCase(), everything functions as expected. But for some reason, looping through individual characters in an array doesn't yield the desired outcome! Is there a specific property of arrays/strings in JavaScript that I'm missing?
In response to RGraham's point about string immutability preventing modification, I find myself puzzled by the community's negative reaction. The validity of the question is clear to me.