I'm very new to Javascript, and I could use some help troubleshooting. In the console log it says "upper" and "wordcount" are not defined. The goal of this function is to loop through an array derived from an inputdiv and ask if the array value is present in that array, AND is NOT present in the "wordcount" array, and if it's not, to push it in.
function processtext() {
var textindiv = document.getElementById("inputdiv").innerHTML;
var split = textindiv.split(" ");
var upper = [];
var wordcount = [];
for (var i = 0; i < split.length; ++i) {
upper.push(split[i].toUpperCase());
}
var sortedlist = upper.sort();
var wordcount = new Array;
for (var i = 0; i < sortedlist.length; ++i) {
if (sortedlist.indexOf(sortedlist[i]) > -1) {
if (wordcount.indexOf(sortedlist[i]) == -1) {
wordcount.push(sortedlist[i]);
}
}
}
}
console.log(upper);
console.log(wordcount);