Traitement de chaine de caractére en js

bouchra -  
 bouchra -
salut tout le monde,
j'aimerai bien avoir le code en javascript qui transforme la chaine de caractére "comment ca marche" en "Comment Ca Marche"
merci

2 réponses

  1. Utilisateur anonyme
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    
    <html>
    <!--
    	Author: Philippe Fery
    	Creation: Augustus 4, 2004
    	philippefery@hotmail.com
    -->
    <head>
    	<title>Untitled</title>
    	<script>
    		function allWordsUpper(text){
    			newText = "";
    			words = text.split(" ");
    			for(i=0 ; i<words.length ; i++){
    				word = words[i];
    				word = word.substring(0,1).toUpperCase() + word.substring(1,word.length);
    				newText +=word;
    				if(i!=words.length-1){
    					newText += " ";
    				}
    			}
    			return newText;
    		}
    	</script>
    </head>
    
    <body>
    	<script>
    		alert(allWordsUpper("comment ça marche"));
    	</script>
    </body>
    </html>
    


    ;-)
    0
    1. bouchra
       
      bonjour,
      je vous remercie infiniment pour votre reponse.
      vraiment c'est trés gentil.
      bonne journée
      0