Advertisement
NubeColectiva

Como Crear Letra Capital con JavaScript

Jun 21st, 2024
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.37 KB | Source Code | 0 0
  1. // Capitalizar un String completo
  2. mistring = "nube colectiva";
  3. a = mistring.toUpperCase();
  4. //console.log(a);
  5.  
  6. // Capitalizar la primera letra de un String
  7. b = mistring.replace(/^\w/, (c) => c.toUpperCase());
  8. //console.log(b);
  9.  
  10. // Capitalizar todas las letras de un String
  11. c = mistring.replace(/\w\S*/g, (w) => (w.replace(/^\w/, (c) => c.toUpperCase())));
  12. console.log(c);
Tags: JavaScript js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement