letter and word counting functions in javascript
function wordarray(x) {
return x.split(" ");
}
function letterarray(x) {
return x.split("");
}
function wordcount(x) {
return wordarray(x).length;
}
function lettercount(x) {
return x.split("").length;
}
function countspecword(x, word) {
var count = 0;
var wordlist = x.split(" ")
for (i = 0; i < wordlist.length; i++) {
if (wordlist[i] == word) {
count++;
}
}
return count;
}
function countspecletter(x, letter) {
var count = 0;
var letterlist = x.split("")
for (i = 0; i < letterlist.length; i++) {
if (letterlist[i] == letter) {
count++;
}
}
return count;
}