2021-03-31 21:56:49 -04:00

21 lines
456 B
JavaScript

function calcWordFrequencies() {
var userInput = prompt();
var userList = userInput.split(" ");
let count = 0;
let removeMe;
for (i=0;i<userList.length;i++){
count = userList.filter(
function(x){ return x === userList[i]; }).length;
console.log(userList[i] + " " + count);
count = 0;
removeMe = userList[i];
if (userList.indexOf(userList[i] != -1)){
userList = userList.filter(function(a){return a !== removeMe})
i--;
}
}
}