let name = "angel";
name = name.charAt(0).toUpperCase(0) + name.slice(0)
When I add 0, it adds another a at the beginning of the string(“Aangel” like that), but when I add 1, it doesn’t add another A and it capitalizes it? can someone explain why?
const name = 'angel'
console.log(name.length) // 5
String.slice(begin, end) copies a section of a string. If no end argument is given it will slice to the last character of the string. So slice(1) will slice from and including index 1 to the last character index.
e.g. 'angel'.slice(1) // -> 'ngel'
I would recommend having a read of the MDN link for String.slice