Advertisement
boris-ivanov

Untitled

Jul 8th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const capitalize=(str)=>{
  2. let array=str.split('')
  3. let arr=[]
  4. for (let i = 0; i < array.length; i++) {
  5. if (i==0 && array[i].charCodeAt()<=92) {
  6. arr.push(array[i])
  7. }else if(i==0 && array[i].charCodeAt()>92) {
  8. let strin= array[i].charCodeAt()
  9. arr.push(String.fromCharCode(strin-32))
  10. }else if (array[i].charCodeAt()>=92) {
  11. arr.push(array[i])
  12. }else{
  13. let strin= array[i].charCodeAt()
  14. arr.push(String.fromCharCode(strin+32))
  15. }
  16. }
  17. return arr.join(',').replace(/,/g, '')
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement