Return to Snippet

Revision: 49659
at July 27, 2011 20:40 by vetri02


Initial Code
function splitWordNumero(bar){
    var foo = bar;
    //var foo = "The quick brown fox jumps over the lazy dog";
    var temp = [];
    var res = [];
   
    temp = foo.split(' ');
    var j = temp.length;
    
    console.log(j);
  
    for(i=0; i<j ; i++) {
        res.push(temp[i]+(i+1));
    }
      
    var ans = res.join(' ');  
  
   //console.log(res.toString());
   console.log (ans);
  document.getElementById('hello').innerHTML = ans;
    
}
 //pasws value here
 splitWordNumero("The quick brown fox jumps over the lazy dog");

Initial URL

                                

Initial Description
This function adds number to each word in a sentence.

Initial Title
Adds number to each word in a sentence

Initial Tags

                                

Initial Language
JavaScript