Hello
In the following code I tried to iterate through strings with for of loop.
It iterates through the first string but not the second. What do I miss?
Your function is only expecting one argument, so ignores the second one. You could either amend your function to accept two arguments, or pass an array as the argument and then iterate it with the for ... of loop inside it.
function uff(a, b) {
const table = {};
for (let char of (a, b).replace(/\W/g, "").toLowerCase()) {
table[char] = table[char] + 1 || 1;
console.log(table);
}
}
uff("hello sun", "ebket");
My problem is that I would like to use the letters as keys and I want to give
a value to each of them, basically count them . This way I got only the second string, but not the first if I console.log (table).