ES6 Map to Array Array.from
function differentSymbolsNaive(str) {
// write code here.
const map = new Map();
const arr = Array.from(str);
for (const item of arr) {
if(!map.has(item)) {
map.set(item, item);
}
}
return [...map].length;
// return [...map.keys()].length;
}
Array.from
const map = new Map().set('a', 1).set('b', 2);
const array = Array.from(map, ([name, value]) => ({ name, value }));
console.log(array);
xgqfrms