how to capitalize a letter based on an index in javascript

Solutions on MaxInterview for how to capitalize a letter based on an index in javascript by the best coders in the world

showing results for - "how to capitalize a letter based on an index in javascript"
Hélène
21 Jul 2019
1function capitalize(s,arr){
2  s = s.split("");
3  for(var i = 0; i < arr.length; i++){
4    if (s[arr[i]] == null) { continue }
5    s[arr[i]]=s[arr[i]].toUpperCase();  
6  }
7  s = s.join('');
8  return s;
9};