/ Published in: JavaScript
                    
                                        
This function adds number to each word in a sentence.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
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");
Comments
 Subscribe to comments
                    Subscribe to comments
                
                