// JavaScript Document
var person = prompt("ENTER INPUT", "");
var count = 0;
var array = person.split(",");
var freq = [];
var words = [];
// Commented lines removed for simplicity
var i = 0, j = 0;
while (array.length > 0) {
var temp = array[0];
while (j < array.length) {
if (temp == array[j]) {
count = count + 1;
array.splice(j, 1);
j = 0;
}
else {
j = j + 1;
}
}
freq[freq.length] = count;
count = 0;
words[words.length] = temp;
}
window.alert(freq + "\n" + words);
Encountering an infinite loop issue when running the code and unable to identify the error. Seeking assistance with debugging this JavaScript function designed to calculate word frequencies in a string input separated by commas. Thank you.