I am working on a function that is meant to add a series of numbers (starting from 1) at the end of each word within a string. Take a look at my current implementation:
function insertNum(str) {
var src = new Array();
src = str.split(" ");
return src[0] + "1 " + src[1] + "2 " + src[2] + "3 " + src[3];
}
insertNum("word word word word."); // should output "word1 word2 word3 word4."
insertNum("word word word."); // should output "word1 word2 word3."